home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / vdl020d.zip / VGEN.DOC < prev    next >
Text File  |  1993-04-14  |  134KB  |  6,752 lines

  1. {
  2. ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix General Functions Unit (VGEN)
  5.  Copyright 1991,92,93 Visionix
  6.  ALL RIGHTS RESERVED
  7.  
  8. ────────────────────────────────────────────────────────────────────────────
  9.  
  10.  Revision history in reverse chronological order:
  11.  
  12.  Initials  Date      Comment
  13.  --------  --------  -------------------------------------------------------
  14.  
  15.  mep       04/04/93  Now Sort works with ShortInt, Byte, Integer, Word,
  16.                      LongInt, String, PString, Real, and "User-supplied"
  17.                      arrays (ie. Records).
  18.  
  19.  mep       03/29/93  Now uses TDecHex in VTypes.
  20.                      Renamed PurgeTypeAheadBuffer to PurgeKbdBuf.
  21.  
  22.  mep       03/26/93  Now works with VBios.
  23.  
  24.  lpg       03/12/93  Completed Source Code Commenting
  25.  
  26.  lpg       03/11/93  Fixed Bug in BinToChar, IsHexByte
  27.                      Added: HexToDecStr
  28.                      Modified: DecToHexStr
  29.  
  30.  lpg       03/11/93  Added Source Commenting
  31.  
  32.  jrt       03/08/93  Moved DOS functions into unit VDOSHIGH
  33.  
  34.  jrt       02/15/93  Documentation integration and misc changes.
  35.                        Renamed FirstString --> ProperString
  36.  
  37.  mep       02/11/93  Cleaned up code for beta release
  38.                      Fixed SetKeyRate and DisketteStatus for DPMI mode.
  39.  
  40.  jrt       2/08/93   Sync with Beta 0.12
  41.  
  42.  mep       2/02/93   Added: DecToHexStr
  43.  
  44.  mep       1/31/93   Added: FileCRC32, CRC32String, FileCRC16,
  45.                        and CRC16String.
  46.                      Changed CRC32 to CRC32Char and CRC32Buffer.
  47.                      Changed CRC16 to CRC16Char and CRC16Buffer.
  48.  
  49.  lpg       1/12/92   Modified: Trim
  50.                      Added: TrimChar
  51.                      Updated: DisketteStatus
  52.  
  53.  mep       1/2/93    Fixed: DeleteChars, UpperString, FirstString, PosCount,
  54.                        StrToAsciiZ, AsciiZtoStr, Sort, PurgeTypeAheadBuffer.
  55.                      Added: FillWord, KeyboardOff, KeyboardOn.
  56.  
  57.  lpg       12/27/92  Cleaned up unnecessary Code
  58.  
  59.  mep       12/22/92  Fixed PosNext, PosNextDelimit - TP70 bug.
  60.                      Added: UnPutDot, PosAfter and PosBefore.
  61.  
  62.  mep       12/19/92  Fixed AddCommas.
  63.  
  64.  mep       12/16/92  Fixed FileExist only include file types
  65.                        (not Directory and VolumeID).
  66.                      Added: AddCommas.
  67.  
  68.  jrt       12/15/92  Changes for bp 7.0:
  69.                        Added code to linear<-->ptr functions to support
  70.                        pascal 7.0; changed PurgeTypeAheadBuffer to use
  71.                        Seg0040 constant instead of direct value.
  72.  
  73.  mep       12/09/92  Fixed InDir, PutSlash, FileExist, GetFileTime,
  74.                        GetFileSize, DirEmpty.
  75.                      Added: TakeWord, TakeQuote, UnPutSlash, and MkSubDir.
  76.  
  77.  mep       12/08/92  Fixed CRC32 to work correctly.
  78.                      Added credits at end of unit.
  79.  
  80.  jrt       12/07/92  Sync with beta 0.11 release
  81.  
  82.  mep       12/06/92  Made CompareSmaller assembly.
  83.                      Fixed Sort, PutSlash, SwapBuffers.
  84.                      Added: CopyOverStr, PosCount;
  85.  
  86.  jrt       12/02/92  Added: PtrToLin, LinToPtr, Ptr math functions,
  87.                        NewString and DisposeString.
  88.  
  89.  mep       12/01/92  Added: CopyStr, PutSlash, PutDot, FileExist, GetFileTime,
  90.                        GetFileAttr, GetFileSize, DirExist, DirEmpty,
  91.                        PredDir, InDir, MaskWildcards
  92.  
  93.  mep       11/30/92  Sync update. Beta 0.10
  94.  
  95.  mep       11/29/92  Sync update.
  96.                      Changed: SwapBuffers, Compare, CompareSmaller
  97.  
  98.  lpg       11/28/92  Added: DecToBCD, BCDtoDec, ByteToBCD, BCDtoByte,
  99.                        WordToBCD, BCDtoWord, GetDOSVersion, DisketteStatus,
  100.                        and FloppyReady.
  101.  
  102.  mep       11/25/92  Overlooked code and updated few bugs.
  103.                      Cleaned-up code.
  104.                      Re-implemented FastCompare.
  105.  
  106.  jrt       11/21/92  Sync with beta 0.08
  107.  
  108.  lpg       11/19/92  Corrected LowerChar, ArrayZtoStr, StrToArrayZ
  109.  
  110.  lpg       11/19/92  Added: ByteToBin, IntToBin, WordToBin, LongToBin,
  111.                        BinToChar, BinToByte, BinToInt, BinToWord, BinToLong
  112.  
  113.  jrt       11/18/92  Got rid of swapNoBuff functions; set greater/lesser
  114.                        code back to pascal on funcs that deal with signed
  115.                        values
  116.  
  117.  jrt       11/11/92  Converted Swap funcs and Greater/lesser funcs to
  118.                        asm code for performance.
  119.  
  120.  lpg       11/10/92  Added ValidByte, ValidInt, ValidLong, ValidFloat,
  121.                        ValidSci, ValidHexByte, ValidHexWord, ValidHex.
  122.  
  123.  mep       11/06/92  Changed PosNextField to return SubS if '=' not found.
  124.  
  125.  lpg       11/01/92  Added Dollar Conversion Functions
  126.  
  127.  lpg       10/19/92  Moved Date/Time functions to VDATES
  128.  
  129.  lpg       10/18/92  Added IncTime, DecTime, IncDate, DecDate, IncDateTime,
  130.                        DecDateTime, AddTime, SubTime, AddDate, SubDate,
  131.                        AddDateTime, SubDateTime, SoundexPack, SoundexUnPack
  132.  
  133.  lpg       10/08/92  Added MarkTime, Modified ClockOn/Off to use MarkTime
  134.                        SwapByteNoBuff, SwapIntNoBuff, SwapWordNoBuff,
  135.                        PosNextDelimit
  136.  
  137.  mep       10/06/92  Fixed Sort for ANY type.
  138.                      Removed CompareBytes - now use CompareBuffers.
  139.                      Removed FastCompare - now use Compare
  140.                      Updated SwapBuffers.
  141.  
  142.  mep       10/03/92  Added NEW functions:
  143.                        GetCurrDateTime, DateTimeOK, DateTimeStr, StrDateTime,
  144.                        DateTimeLinear, LinearDateTime, PosNext, PosNextField,
  145.                        PosNextData, Compare, SetKeyRate, SetKeyFast,
  146.                        FirstString, PurgeTypeAheadBuffer,
  147.                        CRC16, CRC32, Sort, SwapBuffers, CompareBuffers.
  148.  
  149.                      Organization of code.
  150.  
  151.                      Changed functions:
  152.                        StrToArray, StrToArrayZ, ArrayZtoStr
  153.  
  154.  lpg       10/01/92  Added More Functions.
  155.  
  156.  jrt       09/01/92  First logged revision.
  157.  
  158. ════════════════════════════════════════════════════════════════════════════
  159.  
  160. NOT DONE:
  161.  
  162.   Function DecToHexStr(                S         : STRING   ) : STRING;
  163.  
  164. }
  165.  
  166. (*-
  167.  
  168. [SECTION: Section 1: The General Libraries]
  169. [CHAPTER: Chapter 1: The General Functions Libraries]
  170.  
  171. [TEXT]
  172.  
  173.  
  174. <yodle fodle>
  175.  
  176. The general functions library contains several mish-mash and doo-paa
  177. functions that help with general everyday programing chores such as
  178. taking _out_ the ~garbage~, cleaning your room, and doing the dishes.
  179.  
  180. The general function library is broken up into several categories:
  181.  
  182.   <<The smitty foo-bah functions>>
  183.  
  184.     the smitty foo-bah functions assist with the general ka'ichs pormal
  185.     dorshinglefangle corpus d'ahnk.  ==bold is cool== or is it not?
  186.  
  187.   <<The dongle-w'achci functions>>
  188.  
  189.     the smitty foo-bah functions assist with the general ka'ichs pormal
  190.     dorshinglefangle corpus d'ahnk.
  191.  
  192.   <<The smig-for-kahn functions>>
  193.  
  194.   [FILE:VTEST.PAS]
  195.  
  196.   [GRAPHIC:SDFS.EPS]
  197.  
  198.     the smitty foo-bah functions assist with the general ka'ichs pormal
  199.     dorshinglefangle corpus d'ahnk.
  200.  
  201.     <<<tingle-kahn-for>>>
  202.  
  203.       smitty witth ka chi mo bo
  204.  
  205.       zang forn lack for me to be
  206.  
  207.       +++++++++++++++++++++++++++++++++++++++++++++++
  208.       +                                             +
  209.       + Note:  The small poo bear will often yell   +
  210.       | yogle at piglet.  This should be ignored    +
  211.       + except when in an interrupt handler.        +
  212.       +                                             +
  213.       +++++++++++++++++++++++++++++++++++++++++++++++
  214.  
  215.  
  216.   <<the return until functions>>
  217.  
  218.  
  219.  
  220. -*)
  221.  
  222. UNIT VGen;
  223.  
  224.  
  225.  
  226. Uses
  227.  
  228.   DOS,
  229.   VBios,
  230.   VTypes;
  231.  
  232. {────────────────────────────────────────────────────────────────────────────}
  233.  
  234. Type
  235.  
  236.   TPad  =  ( Left, Center, Right );
  237.  
  238.   {---}
  239.  
  240.   TSortProc = Function( Var A; Var B ) : SHORTINT;
  241.   PSortProc = ^TSortProc;
  242.  
  243. {────────────────────────────────────────────────────────────────────────────}
  244.  
  245. {----------------------}
  246. { Character and String }
  247. {----------------------}
  248.  
  249. Function  DeleteChars(            S              : STRING;
  250.                                   Ch             : CHAR         ) : STRING;
  251.  
  252. Function  UpperChar(              C              : CHAR         ) : CHAR;
  253.  
  254. Function  UpperString(            S              : STRING       ) : STRING;
  255.  
  256. Function  ProperString(           S              : STRING       ) : STRING;
  257.  
  258. Function  Pad(                    S              : STRING;
  259.                                   Len            : BYTE;
  260.                                   TypeOPad       : TPad;
  261.                                   Ch             : CHAR         ) : STRING;
  262.  
  263. Function  Trim(                   S              : STRING;
  264.                                   Len            : BYTE;
  265.                                   TypeOTrim      : TPad         ) : STRING;
  266.  
  267. Function  TrimChar(               S              : STRING;
  268.                                   TypeOTrim      : TPad;
  269.                                   Ch             : CHAR         ) : STRING;
  270.  
  271. Function  LowerChar(              Ch             : CHAR         ) : CHAR;
  272.  
  273. Function  LowerString(            S              : STRING       ) : STRING;
  274.  
  275. Function  SR(                     Master,
  276.                                   LookFor,
  277.                                   ReplaceWith   : STRING        ) : STRING;
  278.  
  279.  
  280.  
  281. Function  GetNextParam(           SubS          : STRING;
  282.                                   S             : STRING        ) : STRING;
  283.  
  284.  
  285. Function  GetNextParamEx(         SubS          : STRING;
  286.                                   S             : STRING;
  287.                                   Delimiter     : CHAR          ) : STRING;
  288.  
  289.  
  290. Function  GetParamName(           SubS          : STRING        ) : STRING;
  291.  
  292.  
  293. Function  GetParamData(           SubS          : STRING        ) : STRING;
  294.  
  295.  
  296.  
  297.  
  298. Function  PosBefore(              SubS           : STRING;
  299.                                   S              : STRING;
  300.                                   Index          : BYTE         ) : BYTE;
  301.  
  302. Function  PosAfter(               SubS           : STRING;
  303.                                   S              : STRING;
  304.                                   Index          : BYTE         ) : BYTE;
  305.  
  306. Function  PosEnd(                 Subs           : STRING;
  307.                                   S              : STRING       ) : BYTE;
  308.  
  309. Function  CopyStr(                S1             : STRING;
  310.                                   Index          : INTEGER;
  311.                                   Count          : INTEGER      ) : STRING;
  312.  
  313. Function  CopyOverStr(            S1             : STRING;
  314.                                   S2             : STRING;
  315.                                   Index          : INTEGER;
  316.                                   Count          : INTEGER      ) : STRING;
  317.  
  318.  
  319. Function  OccurStr(               SubS           : STRING;
  320.                                   S              : STRING       ) : BYTE;
  321.  
  322.  
  323. Function  TakeWord(           Var S              : STRING       ) : STRING;
  324.  
  325. Function  TakeQuote(          Var S              : STRING       ) : STRING;
  326.  
  327. Function  AddCommas(              S              : STRING       ) : STRING;
  328.  
  329. Procedure CRC16String(            S              : STRING;
  330.                               Var Result         : WORD;
  331.                                   NewResult      : BOOLEAN      );
  332.  
  333.  
  334. Procedure CRC32String(            S              : STRING;
  335.                               Var Result         : LONGINT;
  336.                                   NewResult      : BOOLEAN      );
  337.  
  338.  
  339. {---------------------}
  340. { Validation Routines }
  341. {---------------------}
  342.  
  343. Function  ValidByte(              S             : STRING        ) : BOOLEAN;
  344.  
  345. Function  ValidInt(               S             : STRING        ) : BOOLEAN;
  346.  
  347. Function  ValidLong(              S             : STRING        ) : BOOLEAN;
  348.  
  349. Function  ValidFloat(             S             : STRING        ) : BOOLEAN;
  350.  
  351. Function  ValidSci(               S             : STRING        ) : BOOLEAN;
  352.  
  353. Function  ValidHexByte(           S             : STRING        ) : BOOLEAN;
  354.  
  355. Function  ValidHexWord(           S             : STRING        ) : BOOLEAN;
  356.  
  357. Function  ValidHex(               S             : STRING        ) : BOOLEAN;
  358.  
  359.  
  360. Function  IsAlpha(                C             : CHAR          ) : BOOLEAN;
  361.  
  362. Function  IsNum(                  C             : CHAR          ) : BOOLEAN;
  363.  
  364. Function  IsAlphaNum(             C             : CHAR          ) : BOOLEAN;
  365.  
  366. Function  IsUpCase(               C             : CHAR          ) : BOOLEAN;
  367.  
  368. Function  IsLoCase(               C             : CHAR          ) : BOOLEAN;
  369.  
  370. Function  IsGrammar(              C             : CHAR          ) : BOOLEAN;
  371.  
  372. Function  IsCtrl(                 C             : CHAR          ) : BOOLEAN;
  373.  
  374. Function  IsBorder(               C             : CHAR          ) : BOOLEAN;
  375.  
  376. Function  IsLang(                 C             : CHAR          ) : BOOLEAN;
  377.  
  378. Function  IsSymbol(               C             : CHAR          ) : BOOLEAN;
  379.  
  380.  
  381. {------------------}
  382. { Type Conversions }
  383. {------------------}
  384.  
  385. Function  IntToStr(               L             : LONGINT       ) : STRING;
  386.  
  387. Function  StrToInt(               S             : STRING        ) : LONGINT;
  388.  
  389. Function  RealToStr(              R             : REAL;
  390.                                   Field         : INTEGER;
  391.                                   Decimals      : INTEGER       ) : STRING;
  392.  
  393. Function  StrToReal(              S             : STRING        ) : REAL;
  394.  
  395. Function  SciToStr(               R             : REAL          ) : STRING;
  396.  
  397. Function  StrToSci(               S             : STRING        ) : REAL;
  398.  
  399. Function  IntToText(              L             : LONGINT       ) : ST80;
  400.  
  401. Function  LongToDollars(          L             : LONGINT       ) : REAL;
  402.  
  403. Function  DollarsToLong(          R             : REAL          ) : LONGINT;
  404.  
  405.  
  406. {--------------------------}
  407. { String Array Conversions }
  408. {--------------------------}
  409.  
  410. Procedure StrToArray(             S             : STRING;
  411.                               Var TheArray                      );
  412.  
  413. Function  ArrayToStr(         Var TheArray;
  414.                                   Len           : BYTE          ) : STRING;
  415.  
  416. Procedure StrToAsciiZ(            S             : STRING;
  417.                               Var AsciiZStr                     );
  418.  
  419. Function  AsciiZtoStr(        Var AsciiZStr                     ) : STRING;
  420.  
  421.  
  422. {---------------}
  423. { Hex functions }
  424. {---------------}
  425.  
  426. Function  CharToHex(              C             : SHORTINT      ) : ST80;
  427.  
  428. Function  ByteToHex(              B             : BYTE          ) : ST80;
  429.  
  430. Function  IntToHex(               I             : INTEGER       ) : ST80;
  431.  
  432. Function  WordToHex(              W             : WORD          ) : ST80;
  433.  
  434. Function  PtrToHex(               P             : POINTER       ) : ST80;
  435.  
  436. Function  LongToHex(              L             : LONGINT       ) : ST80;
  437.  
  438. Function  DecToHexStr(            S             : STRING        ) : STRING;
  439.  
  440. Function  HexToDecStr(            S             : STRING        ) : STRING;
  441.  
  442. Function  HexToChar(              S             : ST80          ) : SHORTINT;
  443.  
  444. Function  HexToByte(              S             : ST80          ) : BYTE;
  445.  
  446. Function  HexToInt(               S             : ST80          ) : INTEGER;
  447.  
  448. Function  HexToWord(              S             : ST80          ) : WORD;
  449.  
  450. Function  HexToLong(              S             : ST80          ) : LONGINT;
  451.  
  452.  
  453. {------------------}
  454. { Binary Functions }
  455. {------------------}
  456.  
  457. Function  ByteToBin(              B             : BYTE          ) : ST80;
  458.  
  459. Function  IntToBin(               I             : INTEGER       ) : ST80;
  460.  
  461. Function  WordToBin(              W             : WORD          ) : ST80;
  462.  
  463. Function  LongToBin(              L             : LONGINT       ) : ST80;
  464.  
  465.  
  466. Function  BinToChar(              S             : ST80          ) : SHORTINT;
  467.  
  468. Function  BinToByte(              S             : ST80          ) : BYTE;
  469.  
  470. Function  BinToInt(               S             : ST80          ) : INTEGER;
  471.  
  472. Function  BinToWord(              S             : ST80          ) : WORD;
  473.  
  474. Function  BinToLong(              S             : ST80          ) : LONGINT;
  475.  
  476.  
  477. {-----------------}
  478. { BCD Conversions }
  479. {-----------------}
  480.  
  481. Function  DecToBCD(               Decimal       : BYTE          ) : BYTE;
  482.  
  483. Function  BCDtoDec(               Bcd           : BYTE          ) : BYTE;
  484.  
  485. Function  ByteToBCD(              Decimal       : BYTE          ) : WORD;
  486.  
  487. Function  BCDtoByte(              Bcd           : WORD          ) : BYTE;
  488.  
  489. Function  WordToBCD(              Decimal       : WORD          ) : LONGINT;
  490.  
  491. Function  BCDtoWord(              Bcd           : LONGINT       ) : WORD;
  492.  
  493.  
  494. (* NOT IMPLEMENTED YET...
  495.  
  496. {---------------------------------------------}
  497. { Generic numeric string to value conversions }
  498. {---------------------------------------------}
  499.  
  500. Function  StrToByteEx(            S            : STRING         ) : BYTE;
  501.  
  502. Function  StrToWordEx(            S            : STRING         ) : WORD;
  503.  
  504. Function  StrToIntEx(             S            : STRING         ) : INTEGER;
  505.  
  506. Function  StrToLongEx(            S            : STRING         ) : LONGINT;
  507.  
  508. *)
  509.  
  510. {--------------------}
  511. { Variable Comparing }
  512. {--------------------}
  513.  
  514. Function  FastCompare(        Var Buf1;
  515.                               Var Buf2;
  516.                                   Count         : WORD          ) : WORD;
  517.  
  518. Function  Compare(            Var Buf1;
  519.                               Var Buf2;
  520.                                   Count         : WORD          ) : WORD;
  521.  
  522. Function  CompareSmaller(     Var Buf1;
  523.                               Var Buf2;
  524.                                   Count         : WORD          ) : SHORTINT;
  525.  
  526. Function  CompareBufByte(     Var Buff;
  527.                                   Count         : WORD;
  528.                                   B             : BYTE          ) : WORD;
  529.  
  530. Function  CompareBufWord(     Var Buff;
  531.                                   Count         : WORD;
  532.                                   W             : WORD          ) : WORD;
  533.  
  534. Function  LookupByte(             InByte        : BYTE;
  535.                                   Count         : WORD;
  536.                               Var LTable;
  537.                               Var OutByte       : BYTE          ) : BOOLEAN;
  538.  
  539. Function  LookupWord(             InWord        : WORD;
  540.                                   Count         : WORD;
  541.                               Var LTable;
  542.                               Var OutWord       : WORD          ) : BOOLEAN;
  543.  
  544. Procedure SwapBuffers(        Var Buf1;
  545.                               Var Buf2;
  546.                                   Count         : WORD          );
  547.  
  548. Procedure SwapWords(          Var A,
  549.                                   B             : WORD          );
  550.  
  551. Procedure SwapInts(           Var A,
  552.                                   B             : INTEGER       );
  553.  
  554. Procedure SwapBytes(          Var A,
  555.                                   B             : BYTE          );
  556.  
  557. Function  GreaterInt(             A,
  558.                                   B             : INTEGER       ) : INTEGER;
  559.  
  560. Function  GreaterWord(            A,
  561.                                   B             : WORD          ) : WORD;
  562.  
  563. Function  GreaterLong(            A,
  564.                                   B             : LONGINT       ) : LONGINT;
  565.  
  566. Function  LesserInt(              A,
  567.                                   B             : INTEGER       ) : INTEGER;
  568.  
  569. Function  LesserWord(             A,
  570.                                   B             : WORD          ) : WORD;
  571.  
  572. Function  LesserLong(             A,
  573.                                   B             : LONGINT       ) : LONGINT;
  574.  
  575. Procedure FillWord(           Var Buf;
  576.                                   Count         : WORD;
  577.                                   Value         : WORD          );
  578.  
  579. Procedure FillLong(           Var Buf;
  580.                                   Count         : WORD;
  581.                                   Value         : LONGINT       );
  582.  
  583. {----------------}
  584. { System and CPU }
  585. {----------------}
  586.  
  587. Procedure RebootMachine(          WarmBoot      : BOOLEAN       );
  588.  
  589. Procedure SetKeyRate(             Delay         : BYTE;
  590.                                   Rate          : BYTE          );
  591. Procedure SetKeyFast;
  592.  
  593. Procedure PurgeKbdBuf;
  594.  
  595. Procedure KeyboardOff;
  596.  
  597. Procedure KeyboardOn;
  598.  
  599. {---------------}
  600. { Miscellaneous }
  601. {---------------}
  602.  
  603. Procedure CRC16Char(          Var Ch            : CHAR;
  604.                               Var Result        : WORD          );
  605.  
  606. Procedure CRC16Buffer(        Var Buf;
  607.                                   Count         : WORD;
  608.                               Var Result        : WORD          );
  609.  
  610. Procedure CRC32Char(          Var Ch            : CHAR;
  611.                               Var Result        : LONGINT       );
  612.  
  613. Procedure CRC32Buffer(        Var Buf;
  614.                                   Count         : WORD;
  615.                               Var Result        : LONGINT       );
  616.  
  617. Procedure Sort(               Var Buf;
  618.                                   Index         : WORD;
  619.                                   Count         : WORD;
  620.                                   SortProc      : PSortProc;
  621.                                   Params        : STRING        );
  622.  
  623. Function  SoundexPack(            S             : STRING        ) : WORD;
  624.  
  625. Function  SoundexUnPack(          W             : WORD          ) : STRING;
  626.  
  627. Function  SoundexStr(             S             : STRING        ) : STRING;
  628.  
  629.  
  630. Function  PtrToLin(               Ptr           : POINTER       ) : LONGINT;
  631.  
  632. Function  LinToPtr(               Lin           : LONGINT       ) : POINTER;
  633.  
  634. Function  PtrAdd(                 OrigPtr       : POINTER;
  635.                                   AddOfs        : LONGINT       ) : POINTER;
  636.  
  637. Function  PtrSub(                 OrigPtr       : POINTER;
  638.                                   SubOfs        : LONGINT       ) : POINTER;
  639.  
  640. Function  NewString(              S             : STRING        ) : POINTER;
  641.  
  642. Function  GetHeapString(          HeapStringPtr : PString       ) : STRING;
  643.  
  644.  
  645. Procedure DisposeString(          PrevNewString : PString       );
  646.  
  647.  
  648. Procedure FarCall(                Proc          : POINTER       );
  649.  
  650.  
  651. {════════════════════════════════════════════════════════════════════════════}
  652.  
  653.  
  654.  
  655. ──────────────────────────────────────────────────────────────────────────────
  656.  
  657.  
  658. [FUNCTION]
  659.  
  660. Function  DeleteChars(            S              : STRING;
  661.                                   Ch             : CHAR         ) : STRING;
  662.  
  663. [PARAMETERS]
  664.  
  665. S           Source String from which to Remove Characters
  666. Ch          Character to Search for and Delete from String
  667.  
  668. [RETURNS]
  669.  
  670. String "S" with all instances of character "Ch" removed.
  671.  
  672. [DESCRIPTION]
  673.  
  674. Deletes all instances of the specified character from the
  675. specified string.
  676.  
  677. [SEE-ALSO]
  678.  
  679. (none)
  680.  
  681. [EXAMPLE]
  682.  
  683. VAR
  684.   S : STRING;
  685.  
  686. BEGIN
  687.  
  688.   S := 'V-I-S-I-O-N-I-X';
  689.   S := DeleteChars( S, '-' );
  690.  
  691.   { S now equals 'VISIONIX' }
  692.  
  693. END;
  694.  
  695.  
  696. ──────────────────────────────────────────────────────────────────────────────
  697.  
  698.  
  699. [FUNCTION]
  700.  
  701. Function  UpperChar(              C              : CHAR         ) : CHAR;
  702.  
  703. [PARAMETERS]
  704.  
  705. C           The character to convert to Upper Case
  706.  
  707. [RETURNS]
  708.  
  709. The Character converted to Upper Case
  710.  
  711. [DESCRIPTION]
  712.  
  713. Converts a Character to Upper Case
  714.  
  715. [SEE-ALSO]
  716.  
  717. LowerChar
  718. UpperString
  719. LowerString
  720. ProperString
  721.  
  722. [EXAMPLE]
  723.  
  724. VAR
  725.   C : CHAR;
  726.  
  727. BEGIN
  728.  
  729.   C := UpperChar( 'a' );
  730.  
  731.   { C now equals 'A' }
  732.  
  733. END;
  734.  
  735.  
  736. ──────────────────────────────────────────────────────────────────────────────
  737.  
  738.  
  739. [FUNCTION]
  740.  
  741. Function  UpperString(               S         : STRING  ) : STRING;
  742.  
  743. [PARAMETERS]
  744.  
  745. S           String to convert to Upper Case
  746.  
  747. [RETURNS]
  748.  
  749. String "S" in all Upper Case
  750.  
  751. [DESCRIPTION]
  752.  
  753. Converts an entire string to upper case.
  754.  
  755. [SEE-ALSO]
  756.  
  757. LowerString
  758. ProperString
  759. UpperChar
  760. LowerChar
  761.  
  762. [EXAMPLE]
  763.  
  764. VAR
  765.   S : STRING;
  766.  
  767. BEGIN
  768.  
  769.   S := 'This is a Test';
  770.   S := UpperString( S );
  771.  
  772.   { S = 'THIS IS A TEST' }
  773.  
  774. END;
  775.  
  776.  
  777. ──────────────────────────────────────────────────────────────────────────────
  778.  
  779.  
  780. [FUNCTION]
  781.  
  782. Function  ProperString(               S         : STRING  ) : STRING;
  783.  
  784. [PARAMETERS]
  785.  
  786. S           String to Modify
  787.  
  788. [RETURNS]
  789.  
  790. String "S" with the First Characters of each word in Upper Case.
  791. All other characters in string "S" are made lower case.
  792.  
  793. [DESCRIPTION]
  794.  
  795. Converts the First Character of each Word in the String to
  796. Upper Case.  Converts all other characters to lower case.
  797.  
  798. [SEE-ALSO]
  799.  
  800. UpperString
  801. LowerString
  802. UpperChar
  803. LowerChar
  804.  
  805. [EXAMPLE]
  806.  
  807. VAR
  808.   S : STRING;
  809.  
  810. BEGIN
  811.  
  812.   S := 'joHN pAUl JOnEs';
  813.   S := ProperString( S );
  814.  
  815.   { S = 'John Paul Jones' }
  816.  
  817. END;
  818.  
  819.  
  820. ──────────────────────────────────────────────────────────────────────────────
  821.  
  822.  
  823. [FUNCTION]
  824.  
  825. Function  Pad(                       S         : STRING;
  826.                                      Len       : BYTE;
  827.                                      TypeOPad  : TPad;
  828.                                      Ch        : CHAR    ) : STRING;
  829.  
  830. [PARAMETERS]
  831.  
  832. S           The string to pad
  833. Len         The desired length of the resulting string
  834. TypeOPad    Type of pad operation you wish to perform
  835.  
  836.                  Left   Adds the pad character to the left of string
  837.                  Right  Adds the pad character to the right of string
  838.                  Center Adds the pad character equally on either side of
  839.                         string
  840. Ch          Character to pad with
  841.  
  842. [RETURNS]
  843.  
  844. The newly padded string based on "S"
  845.  
  846. [DESCRIPTION]
  847.  
  848. Pads the string "S" with the character "Ch" so that the string is
  849. "len" characters in length.  Three types of padding are supported:
  850. LEFT pads the left of the string, RIGHT pads the right, and CENTER
  851. pads on both sides.
  852.  
  853.   ++++++++++++++++++++++++++++++++++++++++++++++++++++
  854.   +                                                  +
  855.   + Note: Pad Left = Right Justified, and visa versa +
  856.   +                                                  +
  857.   ++++++++++++++++++++++++++++++++++++++++++++++++++++
  858.  
  859. [SEE-ALSO]
  860.  
  861. Trim
  862.  
  863. [EXAMPLE]
  864.  
  865. VAR
  866.   S : STRING;
  867.  
  868. BEGIN
  869.  
  870.   {----------------}
  871.   { CENTER padding }
  872.   {----------------}
  873.  
  874.   S := 'Hello, World';
  875.   S := Pad( S, 20, CENTER, '-' );
  876.  
  877.   { S now equals '----Hello, World----' }
  878.  
  879.   {--------------}
  880.   { LEFT padding }
  881.   {--------------}
  882.  
  883.   S := 'Hello, World';
  884.   S := Pad( S, 20, LEFT, '-' );
  885.  
  886.   { T now equals '--------Hello, World' }
  887.  
  888.   {---------------}
  889.   { RIGHT padding }
  890.   {---------------}
  891.  
  892.   S := 'Hello, World';
  893.   S := Pad( S, 20, RIGHT, '-' );
  894.  
  895.   { S now equals 'Hello, World--------' }
  896.  
  897. END;
  898.  
  899.  
  900. ──────────────────────────────────────────────────────────────────────────────
  901.  
  902.  
  903. [FUNCTION]
  904.  
  905. Function  Trim(                      S         : STRING;
  906.                                      Len       : BYTE;
  907.                                      TypeOTrim : TPad   ) : STRING;
  908.  
  909. [PARAMETERS]
  910.  
  911. S           The string to pad
  912. Len         The desired length of the resulting string
  913. TypeOTrim   Type of trim operation you wish to perform
  914.                  Left   Removes characters from the left of the string
  915.                  Right  Removes characters from the right of string
  916.                  Center Removed characters equally on either side of
  917.                         string
  918.  
  919. [RETURNS]
  920.  
  921. The newly trimmed string
  922.  
  923. [DESCRIPTION]
  924.  
  925. Trims the string "S".  If the "TypeOTrim" is LEFT, characters are
  926. removed from the left side of the string until the length of the
  927. string is "len".  If the "TypeOTrim" is RIGHT, characters are
  928. removed from the right side of the string until the length of the
  929. string is "len".  If the "TypeOTrim" is CENTER, characters are
  930. removed from both sides of the string until the length is "len".
  931.  
  932. Trim and Pad are inverse functions - one repairs the other.
  933.  
  934. [SEE-ALSO]
  935.  
  936. Pad
  937.  
  938. [EXAMPLE]
  939.  
  940. VAR
  941.   S : STRING;
  942.  
  943. BEGIN
  944.  
  945.   {-----------}
  946.   { Trim LEFT }
  947.   {-----------}
  948.  
  949.   S := TrimChar( '----Hello, World----', LEFT, 18 )
  950.  
  951.   { S now equals '--Hello, World----' }
  952.  
  953.   {------------}
  954.   { Trim RIGHT }
  955.   {------------}
  956.  
  957.   S := TrimChar( '----Hello, World----', RIGHT, 18 )
  958.  
  959.   { S now equals '----Hello, World--' }
  960.  
  961.   {-------------}
  962.   { Trim CENTER }
  963.   {-------------}
  964.  
  965.   S := TrimChar( '----Hello, World----', CENTER, 18 )
  966.  
  967.   { S now equals '---Hello, World---' }
  968.  
  969. END;
  970.  
  971.  
  972. ──────────────────────────────────────────────────────────────────────────────
  973.  
  974.  
  975. [FUNCTION]
  976.  
  977. Function  TrimChar(                  S         : STRING;
  978.                                      TypeOTrim : TPad;
  979.                                      Ch        : CHAR    ) : STRING;
  980.  
  981. [PARAMETERS]
  982.  
  983. S           The string to pad
  984. TypeOTrim   Type of trim operation you wish to perform
  985.                  Left   Removes a character from the left of the string
  986.                  Right  Removes a character from the right of string
  987.                  Center Removed a character equally on either side of
  988.                         string
  989. Ch          Character to trim from side.  This prevents trimming of part
  990.             of the data which happens to also be of the same pad char.
  991.  
  992. [RETURNS]
  993.  
  994. The newly trimmed string
  995.  
  996. [DESCRIPTION]
  997.  
  998. Trims the string "S".  If the "TypeOTrim" is LEFT, all leading
  999. occurances of the character "CH" are removed from the string.
  1000. If the "TypeOTrim" is RIGHT, all trailing occurances of the character
  1001. "CH" are removed from the string.  If the "TypeOTrim" is CENTER, all
  1002. leading and trailing occurances of the character "CH" are removed
  1003. from the string.
  1004.  
  1005. [SEE-ALSO]
  1006.  
  1007. Pad
  1008. Trim
  1009.  
  1010. [EXAMPLE]
  1011.  
  1012. VAR
  1013.   S : STRING;
  1014.  
  1015. BEGIN
  1016.  
  1017.   {-----------}
  1018.   { Trim LEFT }
  1019.   {-----------}
  1020.  
  1021.   S := TrimChar( '----Hello, World!----', LEFT, '-' )
  1022.  
  1023.   { S now equals 'Hello, World!----' }
  1024.  
  1025.   {------------}
  1026.   { Trim RIGHT }
  1027.   {------------}
  1028.  
  1029.   S := TrimChar( '----Hello, World!----', RIGHT, '-' )
  1030.  
  1031.   { S now equals '----Hello, World!' }
  1032.  
  1033.   {-------------}
  1034.   { Trim CENTER }
  1035.   {-------------}
  1036.  
  1037.   S := TrimChar( '----Hello, World!----', CENTER, '-' )
  1038.  
  1039.   { S now equals 'Hello, World!' }
  1040.  
  1041. END;
  1042.  
  1043.  
  1044. ──────────────────────────────────────────────────────────────────────────────
  1045.  
  1046.  
  1047. [FUNCTION]
  1048.  
  1049. Function  LowerChar(                 Ch        : CHAR    ) : CHAR;
  1050.  
  1051. [PARAMETERS]
  1052.  
  1053. Ch          The character to convert to lowercase
  1054.  
  1055. [RETURNS]
  1056.  
  1057. A lowercase character
  1058.  
  1059. [DESCRIPTION]
  1060.  
  1061. Converts a the specified character to Lower Case.
  1062.  
  1063. [SEE-ALSO]
  1064.  
  1065. UpperChar
  1066. UpperString
  1067. LowerString
  1068.  
  1069. [EXAMPLE]
  1070.  
  1071. VAR
  1072.   C : CHAR;
  1073.  
  1074. BEGIN
  1075.  
  1076.   C := LowerChar( 'A' );
  1077.  
  1078.   { C = 'a' }
  1079.  
  1080. END;
  1081.  
  1082.  
  1083. ──────────────────────────────────────────────────────────────────────────────
  1084.  
  1085.  
  1086. [FUNCTION]
  1087.  
  1088. Function  LowerString(               S         : STRING  ) : STRING;
  1089.  
  1090. [PARAMETERS]
  1091.  
  1092. S           String to convert the lowercase
  1093.  
  1094. [RETURNS]
  1095.  
  1096. A lowercase string.
  1097.  
  1098. [DESCRIPTION]
  1099.  
  1100. Converts the string "S" to lower case.
  1101.  
  1102. [SEE-ALSO]
  1103.  
  1104. LowerChar
  1105. UpperChar
  1106. UpperString
  1107.  
  1108. [EXAMPLE]
  1109.  
  1110. VAR
  1111.   S : STRING;
  1112.  
  1113. BEGIN
  1114.  
  1115.   S := LowerString( 'Now is the TIME for AlL...' );
  1116.  
  1117.   { S now equals 'now is the time for all...' }
  1118.  
  1119. END;
  1120.  
  1121.  
  1122. ──────────────────────────────────────────────────────────────────────────────
  1123.  
  1124.  
  1125. [FUNCTION]
  1126.  
  1127. Function  SR(                        Master,
  1128.                                      LookFor,
  1129.                                      ReplaceWith : STRING) : STRING;
  1130.  
  1131. [PARAMETERS]
  1132.  
  1133. Master      String to perform the search and replace on
  1134. LookFor     String to look for in "Master"
  1135. ReplaceWith String to replace "LookFor" with.
  1136.  
  1137. [RETURNS]
  1138.  
  1139. A new string, based on "Master", that has all occurances of the
  1140. string "LookFor" replaced with "ReplaceWith".
  1141.  
  1142. [DESCRIPTION]
  1143.  
  1144. Using a given String, Searches for the sub-string "Lookfor" and replaces
  1145. all instances with of it with another sub-string, "ReplaceWith"
  1146.  
  1147. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1148. +                                                                 +
  1149. + Note: the SR function can be used to delete all occurances of a +
  1150. + substring within a string by specifying nothing ('') as the     +
  1151. + ReplaceWith parameter.                                          +
  1152. +                                                                 +
  1153. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1154.  
  1155. [SEE-ALSO]
  1156.  
  1157. (none)
  1158.  
  1159. [EXAMPLE]
  1160.  
  1161. VAR
  1162.   S : STRING;
  1163.  
  1164. BEGIN
  1165.  
  1166.   S := SR( 'Now is the time.  Now I Say!', 'Now', 'Tomorrow' );
  1167.  
  1168.   { S now equals 'Tomorrow is the time.  Tomorrow I Say!' }
  1169.  
  1170. END;
  1171.  
  1172.  
  1173. ──────────────────────────────────────────────────────────────────────────────
  1174.  
  1175.  
  1176. [FUNCTION]
  1177.  
  1178. Function  GetNextParam(              SubS      : STRING;
  1179.                                      S         : STRING  ) : STRING;
  1180.  
  1181. [PARAMETERS]
  1182.  
  1183. Subs        Sub-string that preceeds up to the parameter to get
  1184. S           Parameter list to get the next parameter from
  1185.  
  1186. [RETURNS]
  1187.  
  1188. The next Parameter following the given Starting Parameter Sub-String
  1189.  
  1190. [DESCRIPTION]
  1191.  
  1192. This function takes a string of text parameters (delimited by commas) and
  1193. searches for the parameter following the one provided.  The parameter may
  1194. be a single symbol or have a value following it (using an equals sign as
  1195. in the examples below).
  1196. The following Examples illustrate usage:
  1197.   Ex #1 : GetNextParam( 'B=C', 'A=B,B=C,C=D,D=10' ) = 'C=D'
  1198.   Ex #2 : GetNextParam( '',    'A=B,B=C,C=D,D=10' ) = 'A=B'
  1199.   Ex #3 : GetNextParam( 'B',   'A=B,B=C,C=D,D=10' ) = 'C=D'
  1200.  
  1201. [SEE-ALSO]
  1202.  
  1203. GetNextParamEx
  1204. GetParamName
  1205. GetParamData
  1206.  
  1207. [EXAMPLE]
  1208.  
  1209. VAR
  1210.   S,T : STRING;
  1211.  
  1212. BEGIN
  1213.  
  1214.   S := 'Ground=Brown,Sky=Blue,Trees=Green,World=Round';
  1215.   T := '';
  1216.  
  1217.   REPEAT
  1218.  
  1219.     S := GetNextParam( T, S );
  1220.     WriteLn( 'T="', T, '"' );
  1221.  
  1222.   UNTIL T = '';
  1223.  
  1224.   {----------------}
  1225.   { Output:        }
  1226.   {                }
  1227.   { "Ground=Brown" }
  1228.   { "Sky=Blue"     }
  1229.   { "Trees=Green"  }
  1230.   { "World=Round"  }
  1231.   {----------------}
  1232.  
  1233.   S := 'Ground=Brown,Sky=Blue,Trees=Green,World=Round';
  1234.   T := GetNextParam( 'Sky', S );
  1235.  
  1236.   { T = 'Trees=Green' }
  1237.  
  1238. END;
  1239.  
  1240.  
  1241. ──────────────────────────────────────────────────────────────────────────────
  1242.  
  1243.  
  1244. [FUNCTION]
  1245.  
  1246. Function  GetNextParamEx(            SubS      : STRING;
  1247.                                      S         : STRING;
  1248.                                      Delimiter : CHAR    ) : STRING;
  1249.  
  1250. [PARAMETERS]
  1251.  
  1252. Subs        Sub-String that preceeds up to the parameter to get
  1253. S           Parameter list to get the next parameter from
  1254. Delimiter   Sub-String Separator Character
  1255.  
  1256. [RETURNS]
  1257.  
  1258. The next Parameter following the given Starting Parameter Sub-String.
  1259.  
  1260. [DESCRIPTION]
  1261.  
  1262. This function takes a string of text parameters (delimited by the
  1263. specified "Delimiter") and searches for the parameter following the one
  1264. provided.  The parameter may be a single symbol or have a value
  1265. following it (using an equals sign as in the examples below).
  1266.  
  1267. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1268. +                                                                 +
  1269. + Note:  This function is an EXtended version of the GetNextParam +
  1270. + function, with the extension of being able to specify the       +
  1271. + character that seperates the parameters of a parameter string.  +
  1272. +                                                                 +
  1273. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1274.  
  1275. [SEE-ALSO]
  1276.  
  1277. GetNextParam
  1278. GetParamName
  1279. GetParamData
  1280.  
  1281. [EXAMPLE]
  1282.  
  1283. VAR
  1284.   S : STRING;
  1285.  
  1286. BEGIN
  1287.  
  1288.   {------------}
  1289.   { Example #1 }
  1290.   {------------}
  1291.  
  1292.   S := GetNextParam( '',
  1293.                      'Ground=Brown,Sky=Blue|Trees=Green,World=Round',
  1294.                      '|' )
  1295.  
  1296.   { S now equals 'Ground=Brown,Sky=Blue' }
  1297.  
  1298.   {------------}
  1299.   { Example #2 }
  1300.   {------------}
  1301.  
  1302.   S := GetNextParam( 'Ground=Brown,Sky=Blue',
  1303.                      'Ground=Brown,Sky=Blue|Trees=Green,World=Round',
  1304.                      '|' )
  1305.  
  1306.   { S now equals 'Trees=Green,World=Round' }
  1307.  
  1308. END;
  1309.  
  1310.  
  1311. ──────────────────────────────────────────────────────────────────────────────
  1312.  
  1313.  
  1314. [FUNCTION]
  1315.  
  1316. Function  GetParamName(              SubS      : STRING  ) : STRING;
  1317.  
  1318. [PARAMETERS]
  1319.  
  1320. SubS        Source Parameter String
  1321.  
  1322. [RETURNS]
  1323.  
  1324. Parameter Field Name from Source String
  1325.  
  1326. [DESCRIPTION]
  1327.  
  1328. This function returns the parameter name portion of a parameter string.
  1329. The parameter name portion is defined to be "the portion preceding the
  1330. equal sign."
  1331.  
  1332. [SEE-ALSO]
  1333.  
  1334. GetNextParamEx
  1335. PosNextData
  1336.  
  1337. [EXAMPLE]
  1338.  
  1339. VAR
  1340.   S : STRING;
  1341.  
  1342. BEGIN
  1343.  
  1344.   S := GetParamName( 'Trees=Green' );
  1345.  
  1346.   { S now equals 'Trees' }
  1347.  
  1348. END;
  1349.  
  1350.  
  1351. ──────────────────────────────────────────────────────────────────────────────
  1352.  
  1353.  
  1354. [FUNCTION]
  1355.  
  1356. Function  GetParamData(               SubS      : STRING  ) : STRING;
  1357.  
  1358. [PARAMETERS]
  1359.  
  1360. SubS        Source Parameter String with Value
  1361.  
  1362. [RETURNS]
  1363.  
  1364. Parameter Field Value from Source String
  1365.  
  1366. [DESCRIPTION]
  1367.  
  1368. This function returns the data portion of a parameter string.  The
  1369. data portion is defined as "the portion following the equal sign".
  1370.  
  1371. [SEE-ALSO]
  1372.  
  1373. GetNextParamEx
  1374. GetParamName
  1375.  
  1376. [EXAMPLE]
  1377.  
  1378. VAR
  1379.   S : STRING;
  1380.  
  1381. BEGIN
  1382.  
  1383.   S := GetParamData( 'Trees=Green' );
  1384.  
  1385.   { T now equals 'Green' }
  1386.  
  1387. END;
  1388.  
  1389.  
  1390. ──────────────────────────────────────────────────────────────────────────────
  1391.  
  1392.  
  1393. [FUNCTION]
  1394.  
  1395. Function  PosBefore(                 SubS      : STRING;
  1396.                                      S         : STRING;
  1397.                                      Index     : BYTE    ) : BYTE;
  1398.  
  1399. [PARAMETERS]
  1400.  
  1401. SubS        Sub-String to locate
  1402. S           Source String to search
  1403. Index       Limiting Search Index
  1404.  
  1405. [RETURNS]
  1406.  
  1407. Index into Source String where Sub-String was Found
  1408.  
  1409. [DESCRIPTION]
  1410.  
  1411. This function is much like the standard POS function.  PosBefore
  1412. differs in that you can specify the "Index" at which to end the search.
  1413. If the specified "SubS"tring occurs before "Index", it's position will
  1414. be returned.  If it occurs after the "Index", or if it does not occur
  1415. in "S", the function will return a 0.
  1416.  
  1417. [SEE-ALSO]
  1418.  
  1419. PosNext
  1420. PosAfter
  1421. PosEnd
  1422.  
  1423. [EXAMPLE]
  1424.  
  1425. VAR
  1426.   S : STRING;
  1427.  
  1428. BEGIN
  1429.  
  1430.   {------------}
  1431.   { Example #1 }
  1432.   {------------}
  1433.  
  1434.   X := PosBefore( 'World',
  1435.                   'Hello, World!  Whats up?',
  1436.                   11  );
  1437.  
  1438.   (X now equals 0, since the string 'World' does not completely occur
  1439.    before the 11th character in the main string)
  1440.  
  1441.   {------------}
  1442.   { Example #2 }
  1443.   {------------}
  1444.  
  1445.   X := PosBefore( 'World',
  1446.                   'Hello, World!  Whats up?',
  1447.                   20  );
  1448.  
  1449.  
  1450.   {------------------------------------------------------------}
  1451.   { S now equals 8, since the string 'World' occurs before the }
  1452.   { 20th character in the main string, at the 8th character    }
  1453.   {------------------------------------------------------------}
  1454.  
  1455. END;
  1456.  
  1457.  
  1458. ──────────────────────────────────────────────────────────────────────────────
  1459.  
  1460.  
  1461. [FUNCTION]
  1462.  
  1463. Function  PosAfter(                  SubS      : STRING;
  1464.                                      S         : STRING;
  1465.                                      Index     : BYTE    ) : BYTE;
  1466.  
  1467. [PARAMETERS]
  1468.  
  1469. SubS        Sub-String to locate
  1470. S           Source String to search
  1471. Index       Starting Search Index
  1472.  
  1473. [RETURNS]
  1474.  
  1475. Index into Source String where Sub-String was Found
  1476.  
  1477. [DESCRIPTION]
  1478.  
  1479. This function is much like the standard POS function.  PosAfter
  1480. differs in that you can specify the "Index" at which to start the search.
  1481. If the specified "SubS"tring occurs after "Index", it's position will
  1482. be returned.  If it occurs before the "Index", or if it does not occur
  1483. in "S", the function will return a 0.
  1484.  
  1485. [SEE-ALSO]
  1486.  
  1487. Pos
  1488. PosNext
  1489. PosBefore
  1490. PosEnd
  1491.  
  1492. [EXAMPLE]
  1493.  
  1494. VAR
  1495.   B : BYTE;
  1496.  
  1497. BEGIN
  1498.  
  1499.   B := PosAfter( 'Hello', 'Excuse me, but: Hello, World!  Whats up?', 20 );
  1500.  
  1501.   {-----------------------------------------------------------}
  1502.   { B now equals 0, since the complete substring "Hello" does }
  1503.   { not occur after the 20th character of the main string     }
  1504.   {-----------------------------------------------------------}
  1505.  
  1506. END;
  1507.  
  1508.  
  1509. ──────────────────────────────────────────────────────────────────────────────
  1510.  
  1511.  
  1512. [FUNCTION]
  1513.  
  1514. Function   PosEnd(                   Subs      : STRING;
  1515.                                      S         : STRING  ) : BYTE;
  1516.  
  1517. [PARAMETERS]
  1518.  
  1519. SubS        Sub-String
  1520. S           Source String to Search
  1521.  
  1522. [RETURNS]
  1523.  
  1524. Index into Source String where Sub-String was Found
  1525.  
  1526. [DESCRIPTION]
  1527.  
  1528. This function is much like the standard POS function.  PosEnd differs
  1529. in that the Search is started from the end of the string with the
  1530. last Matching Sub-String in the Source String being the Answer.  If
  1531. Found this function will return the Index of the Sub-String into the
  1532. Source String, otherwise it will return 0 (Just like std POS function).
  1533.  
  1534. [SEE-ALSO]
  1535.  
  1536. Pos
  1537. PosNext
  1538. PosBefore
  1539. PosAfter
  1540.  
  1541. [EXAMPLE]
  1542.  
  1543. VAR
  1544.   B : BYTE;
  1545.  
  1546. BEGIN
  1547.  
  1548.   B := PosEnd( 'Hello', 'Excuse me, but: Hello, World!  Whats up?' );
  1549.  
  1550.   { B = 17 }
  1551.  
  1552. END;
  1553.  
  1554.  
  1555. ──────────────────────────────────────────────────────────────────────────────
  1556.  
  1557.  
  1558. [FUNCTION]
  1559.  
  1560. Function  CopyStr(                   S1        : STRING;
  1561.                                      Index     : INTEGER;
  1562.                                      Count     : INTEGER ) : STRING;
  1563.  
  1564. [PARAMETERS]
  1565.  
  1566. S1          Source String to Copy with
  1567. Index       Position in Source String to Start Copy from
  1568. Count       Number of Characters to Copy
  1569.  
  1570. [RETURNS]
  1571.  
  1572. Created String
  1573.  
  1574. [DESCRIPTION]
  1575.  
  1576. This function is like the standard Turbo Pascal "Copy" Command, except
  1577. it is faster.
  1578.  
  1579. [SEE-ALSO]
  1580.  
  1581. CopyOverStr
  1582.  
  1583. [EXAMPLE]
  1584.  
  1585. VAR
  1586.   S : STRING;
  1587.  
  1588. BEGIN
  1589.  
  1590.   S := Copy( 'The Color is Blue.', 14, 4 );
  1591.  
  1592.   { S now equals "Blue" }
  1593.  
  1594. END;
  1595.  
  1596.  
  1597. ──────────────────────────────────────────────────────────────────────────────
  1598.  
  1599.  
  1600. [FUNCTION]
  1601.  
  1602. Function  CopyOverStr(               S1        : STRING;
  1603.                                      S2        : STRING;
  1604.                                      Index     : INTEGER;
  1605.                                      Count     : INTEGER  ) : STRING;
  1606.  
  1607. [PARAMETERS]
  1608.  
  1609. S1          Source String - data to overwrite on S2
  1610. S2          Destination String - portion of which overwritten by S1
  1611. Index       Position into S2 to Start copying
  1612. Count       Number of Characters to Copy
  1613.  
  1614. [RETURNS]
  1615.  
  1616. Resulting modified string.
  1617.  
  1618. [DESCRIPTION]
  1619.  
  1620. This function takes the Source String, and uses it to overwrite a portion
  1621. of the Destination String, starting from the provided Index and for a
  1622. given number of Characters.
  1623.  
  1624. [SEE-ALSO]
  1625.  
  1626. CopyStr
  1627.  
  1628. [EXAMPLE]
  1629.  
  1630. VAR
  1631.   S : STRING;
  1632.  
  1633. BEGIN
  1634.  
  1635.   S := 'The Color is Cyan.';
  1636.   S := CopyOverStr( S, 'Blue', 14, 4 );
  1637.  
  1638.   { S now equals "The Color is Blue." }
  1639.  
  1640. END;
  1641.  
  1642.  
  1643. ──────────────────────────────────────────────────────────────────────────────
  1644.  
  1645.  
  1646. [FUNCTION]
  1647.  
  1648. Function  OccurStr(                  SubS      : STRING;
  1649.                                      S         : STRING   ) : BYTE;
  1650.  
  1651. [PARAMETERS]
  1652.  
  1653. SubS        Sub-String to look for
  1654. S           Source String to Search
  1655.  
  1656. [RETURNS]
  1657.  
  1658. The Number of Times the Sub-String was found in the Source String.
  1659.  
  1660. [DESCRIPTION]
  1661.  
  1662. Searches the Source String for the Sub-String and returns the number
  1663. of times it was found in the Source String.
  1664.  
  1665. [SEE-ALSO]
  1666.  
  1667. Pos
  1668.  
  1669. [EXAMPLE]
  1670.  
  1671. VAR
  1672.   S     : STRING;
  1673.   Count : BYTE;
  1674.  
  1675. BEGIN
  1676.  
  1677.   S     := 'This is the way it is here.';
  1678.   Count := OccurStr( 'is', S );
  1679.  
  1680.   { Count = 3 }
  1681.  
  1682. END;
  1683.  
  1684.  
  1685. ──────────────────────────────────────────────────────────────────────────────
  1686.  
  1687.  
  1688. [FUNCTION]
  1689.  
  1690. Function  TakeWord(              Var S         : STRING   ) : STRING;
  1691.  
  1692. [PARAMETERS]
  1693.  
  1694. S           VAR Source & Modified String to parse
  1695.  
  1696. [RETURNS]
  1697.  
  1698. First Text Word found in the provided Source String
  1699.  
  1700. [DESCRIPTION]
  1701.  
  1702. This function searches the Source String for the first Text Word and
  1703. returns that Word as the function result.  The Source String is modified
  1704. to remove the found word, which may be resubmitted by the caller to
  1705. continue word extractions.
  1706.  
  1707. [SEE-ALSO]
  1708.  
  1709. TakeQuote
  1710.  
  1711. [EXAMPLE]
  1712.  
  1713. VAR
  1714.   S,Tmp : STRING;
  1715.  
  1716. BEGIN
  1717.  
  1718.   S := 'This is a string with 9 words in it';
  1719.  
  1720.   REPEAT
  1721.  
  1722.     Tmp := TakeWord( S );
  1723.     WriteLn( Tmp );  { Writes one word at a time }
  1724.  
  1725.   UNTIL S = '';
  1726.  
  1727. END;
  1728.  
  1729.  
  1730. ──────────────────────────────────────────────────────────────────────────────
  1731.  
  1732.  
  1733. [FUNCTION]
  1734.  
  1735. Function  TakeQuote(             Var S         : STRING   ) : STRING;
  1736.  
  1737. [PARAMETERS]
  1738.  
  1739. S           VAR Source & Modified String to parse
  1740.  
  1741. [RETURNS]
  1742.  
  1743. First Quoted Text found in Source String
  1744.  
  1745. [DESCRIPTION]
  1746.  
  1747. This function searches the Source String for the first Quoted Text
  1748. contained within the provided string and returns this as the function
  1749. result.  The Source String is modified by the elimination of the Quoted
  1750. Text from within this string.
  1751.  
  1752. [SEE-ALSO]
  1753.  
  1754. TakeWord
  1755.  
  1756. [EXAMPLE]
  1757.  
  1758. VAR
  1759.   S,T : STRING;
  1760.  
  1761. BEGIN
  1762.  
  1763.   S := 'The Password is "Zulu"';
  1764.   T := TakeQuote( S );
  1765.  
  1766.   {------------------------}
  1767.   { T = 'Zulu'             }
  1768.   { S = 'The Password is ' }
  1769.   {------------------------}
  1770.  
  1771. END;
  1772.  
  1773.  
  1774. ──────────────────────────────────────────────────────────────────────────────
  1775.  
  1776.  
  1777. [FUNCTION]
  1778.  
  1779. Function  AddCommas(                 S         : STRING   ) : STRING;
  1780.  
  1781. [PARAMETERS]
  1782.  
  1783. S           Text String of a Number
  1784.  
  1785. [RETURNS]
  1786.  
  1787. Number Text with Commas Inserted.
  1788.  
  1789. [DESCRIPTION]
  1790.  
  1791. This function takes a Number in Text format (like "10", not "ten") and
  1792. inserts the commas at the thousands place, etc. until the number has
  1793. been completed.
  1794.  
  1795. [SEE-ALSO]
  1796.  
  1797. (None)
  1798.  
  1799. [EXAMPLE]
  1800.  
  1801. VAR
  1802.   S : STRING;
  1803.  
  1804. BEGIN
  1805.  
  1806.   S := '123456789';
  1807.   S := AddCommas( S );
  1808.  
  1809.   { S = '123,456,789' }
  1810.  
  1811. END;
  1812.  
  1813.  
  1814. ──────────────────────────────────────────────────────────────────────────────
  1815.  
  1816.  
  1817. [FUNCTION]
  1818.  
  1819. Procedure CRC16String(               S         : STRING;
  1820.                                  Var Result    : WORD;
  1821.                                      NewResult : BOOLEAN  );
  1822.  
  1823. [PARAMETERS]
  1824.  
  1825. S           Source String to CRC
  1826. Result      VAR Returned 16-bit CRC of String
  1827. NewResult   Is this an Initial CRC?
  1828.  
  1829. [RETURNS]
  1830.  
  1831. Function : None
  1832. (VAR     : [Result] Returned 16-bit CRC of string)
  1833.  
  1834. [DESCRIPTION]
  1835.  
  1836. Computes a 16-Bit CRC on the source string.  If the NewResult flag is TRUE
  1837. then the Result is based upon the provided string.  If the NewResult Flag is
  1838. FALSE then the result is computed as a continuation of the result already
  1839. provided in the result variable.
  1840.  
  1841. [SEE-ALSO]
  1842.  
  1843. CRC16Char
  1844. CRC16Buffer
  1845. CRC32Char
  1846. CRC32String
  1847. CRC32Buffer
  1848.  
  1849. [EXAMPLE]
  1850.  
  1851. VAR
  1852.   S      : STRING;
  1853.   CRC32  : LONGINT;
  1854.   NewCRC : BOOLEAN;
  1855. BEGIN
  1856.  
  1857. VAR
  1858.   S     : STRING;
  1859.   CRC16 : WORD;
  1860.  
  1861. BEGIN
  1862.  
  1863.   S := 'She sells sea shells down by the sea shore';
  1864.   CRC16String( S, CRC32, TRUE );
  1865.  
  1866.   { CRC16 = $4941 }
  1867.  
  1868. END;
  1869.  
  1870.  
  1871. ──────────────────────────────────────────────────────────────────────────────
  1872.  
  1873. [FUNCTION]
  1874.  
  1875. Procedure CRC32String(               S         : STRING;
  1876.                                  Var Result    : LONGINT;
  1877.                                      NewResult : BOOLEAN  );
  1878.  
  1879. [PARAMETERS]
  1880.  
  1881. S           Source String to CRC
  1882. Result      VAR Returned 32-bit CRC Checksum of String
  1883. NewResult   Is this an Initial CRC Checksum?
  1884.  
  1885. [RETURNS]
  1886.  
  1887. Function : None
  1888. (VAR     : [Result] Returned 32-bit CRC Checksum of String)
  1889.  
  1890. [DESCRIPTION]
  1891.  
  1892. Computes a 32-Bit CRC Checksum on the Source String.  If the NewResult
  1893. Flag is TRUE then the checksum is based wholey upon the provided string
  1894. If the NewResult Flag is FALSE then the Checksum is computed as a
  1895. continuation of the Checksum already provided in the Result Variable.
  1896.  
  1897. [SEE-ALSO]
  1898.  
  1899. CRC16Char
  1900. CRC16String
  1901. CRC16Buffer
  1902. CRC32Char
  1903. CRC32Buffer
  1904.  
  1905. [EXAMPLE]
  1906.  
  1907. VAR
  1908.   S     : STRING;
  1909.   CRC32 : LONGINT;
  1910.  
  1911. BEGIN
  1912.  
  1913.   S := 'She sells sea shells down by the sea shore';
  1914.   CRC32String( S, CRC32, TRUE );
  1915.  
  1916.   { CRC32 = $7C6912A6 }
  1917.  
  1918. END;
  1919.  
  1920.  
  1921. ──────────────────────────────────────────────────────────────────────────────
  1922.  
  1923.  
  1924. [FUNCTION]
  1925.  
  1926.  
  1927. Function  ValidByte(                 S         : STRING  ) : BOOLEAN;
  1928.  
  1929. [PARAMETERS]
  1930.  
  1931. S           String representing a byte value
  1932.  
  1933. [RETURNS]
  1934.  
  1935. Whether that string did represent a byte value
  1936.  
  1937. [DESCRIPTION]
  1938.  
  1939. Returns whether or not the given String represents a Valid Byte
  1940. Value.
  1941.  
  1942. [SEE-ALSO]
  1943.  
  1944. ValidInt      ValidLong     ValidFlot    ValidSci
  1945. ValidHexByte  ValidHexWord  ValidHex
  1946.  
  1947. [EXAMPLE]
  1948.  
  1949. BEGIN
  1950.  
  1951.   WriteLn( ValidByte( '123' ) );  { TRUE  }
  1952.   WriteLn( ValidByte( '345' ) );  { FALSE }
  1953.   WriteLn( ValidByte( 'abc' ) );  { FALSE }
  1954.  
  1955. END;
  1956.  
  1957.  
  1958. ──────────────────────────────────────────────────────────────────────────────
  1959.  
  1960.  
  1961. [FUNCTION]
  1962.  
  1963. Function  ValidInt(                  S         : STRING  ) : BOOLEAN;
  1964.  
  1965. [PARAMETERS]
  1966.  
  1967. S           String representing a Signed Integer value (Word)
  1968.  
  1969. [RETURNS]
  1970.  
  1971. Whether that string did represent a signed integer value
  1972.  
  1973. [DESCRIPTION]
  1974.  
  1975. Returns whether or not the given String represents a Valid
  1976. Integer Value.
  1977.  
  1978. [SEE-ALSO]
  1979.  
  1980. ValidByte
  1981. ValidLong
  1982. ValidFloat
  1983. ValidSci
  1984. ValidHexByte
  1985. ValidHexWord
  1986. ValidHex
  1987.  
  1988. [EXAMPLE]
  1989.  
  1990. BEGIN
  1991.  
  1992.   WriteLn( ValidInt( '12345'  ) );  { TRUE  }
  1993.   WriteLn( ValidInt( '123456' ) );  { FALSE }
  1994.   WriteLn( ValidInt( 'abcdef' ) );  { FALSE }
  1995.  
  1996. END;
  1997.  
  1998.  
  1999. ──────────────────────────────────────────────────────────────────────────────
  2000.  
  2001.  
  2002. [FUNCTION]
  2003.  
  2004. Function  ValidLong(                 S         : STRING  ) : BOOLEAN;
  2005.  
  2006. [PARAMETERS]
  2007. S           String representing a Signed Longint value (Double Word)
  2008.  
  2009. [RETURNS]
  2010.  
  2011. Whether that string did represent a signed longint value
  2012.  
  2013. [DESCRIPTION]
  2014.  
  2015. Returns whether or not the given String represents a Valid
  2016. Long Integer Value.
  2017.  
  2018. [SEE-ALSO]
  2019.  
  2020. ValidByte
  2021. ValidInt
  2022. ValidFloat
  2023. ValidSci
  2024. ValidHexByte
  2025. ValidHexWord
  2026. ValidHex
  2027.  
  2028. [EXAMPLE]
  2029.  
  2030. BEGIN
  2031.  
  2032.   WriteLn( ValidLong( '12345678'     ) );  { TRUE }
  2033.   WriteLn( ValidLong( '999999999999' ) );  { FALSE }
  2034.   WriteLn( ValidLong( 'abcdefgh'     ) );  { FALSE }
  2035.  
  2036. END;
  2037.  
  2038.  
  2039. ──────────────────────────────────────────────────────────────────────────────
  2040.  
  2041.  
  2042. [FUNCTION]
  2043.  
  2044. Function  ValidFloat(                S         : STRING  ) : BOOLEAN;
  2045.  
  2046. [PARAMETERS]
  2047.  
  2048. S           String value representing a floating point value
  2049.  
  2050. [RETURNS]
  2051.  
  2052. Whether that string did represent a floating point value
  2053.  
  2054. [DESCRIPTION]
  2055.  
  2056. Returns whether or not the given String represents a Valid
  2057. Floating Point Value.
  2058.  
  2059. [SEE-ALSO]
  2060.  
  2061. ValidByte
  2062. ValidInt
  2063. ValidLong
  2064. ValidSci
  2065. ValidHexByte
  2066. ValidHexWord
  2067. ValidHex
  2068.  
  2069. [EXAMPLE]
  2070.  
  2071. BEGIN
  2072.  
  2073.   WriteLn( ValidFloat( '123.456' ) );  { TRUE  }
  2074.   WriteLn( ValidFloat( 'abcdefg' ) );  { FALSE }
  2075.  
  2076. END;
  2077.  
  2078.  
  2079. ──────────────────────────────────────────────────────────────────────────────
  2080.  
  2081.  
  2082. [FUNCTION]
  2083.  
  2084. Function  ValidSci(                  S         : STRING  ) : BOOLEAN;
  2085.  
  2086. [PARAMETERS]
  2087.  
  2088. S           String representing a floating point value in scientific
  2089.             notation
  2090.  
  2091. [RETURNS]
  2092.  
  2093. Whether that string did represent a floating point value in scientific
  2094. notation
  2095.  
  2096. [DESCRIPTION]
  2097.  
  2098. Returns whether or not the given String represents a Valid
  2099. Scientific Notation Floating Point Value.
  2100.  
  2101. [SEE-ALSO]
  2102.  
  2103. ValidByte
  2104. ValidInt
  2105. ValidLong
  2106. ValidFloat
  2107. ValidHexByte
  2108. ValidHexWord
  2109. ValidHex
  2110.  
  2111. [EXAMPLE]
  2112.  
  2113. BEGIN
  2114.  
  2115.   WriteLn( ValidSci( '1.234E10' ) );  { TRUE  }
  2116.   WriteLn( ValidSci( '12.34E10' ) );  { TRUE  }
  2117.   WriteLn( ValidSci( '1.234E99' ) );  { FALSE }
  2118.   WriteLn( ValidSci( '1.234X10' ) );  { FALSE }
  2119.   WriteLn( ValidSci( '12345678' ) );  { TRUE  }
  2120.   WriteLn( ValidSci( 'abcdefgh' ) );  { FALSE }
  2121.  
  2122. END;
  2123.  
  2124.  
  2125. ──────────────────────────────────────────────────────────────────────────────
  2126.  
  2127.  
  2128. [FUNCTION]
  2129.  
  2130. Function  ValidHexByte(              S         : STRING  ) : BOOLEAN;
  2131.  
  2132. [PARAMETERS]
  2133.  
  2134. S           String representing Byte value in hex
  2135.  
  2136. [RETURNS]
  2137.  
  2138. Whether that string did represent a byte value in hex
  2139.  
  2140. [DESCRIPTION]
  2141.  
  2142. Returns whether or not the given String represents a Valid
  2143. Byte in Hexadecimal format.
  2144.  
  2145. [SEE-ALSO]
  2146.  
  2147. ValidByte
  2148. ValidInt
  2149. ValidLong
  2150. ValidFloat
  2151. ValidSci
  2152. ValidHexWord
  2153. ValidHex
  2154.  
  2155. [EXAMPLE]
  2156.  
  2157. BEGIN
  2158.  
  2159.   WriteLn( Valid( '1A'   ) );  { TRUE  }
  2160.   WriteLn( Valid( 'Ff'   ) );  { TRUE  }
  2161.   WriteLn( Valid( '1A2b' ) );  { FALSE }
  2162.   WriteLn( Valid( 'zyx'  ) );  { FALSE }
  2163.   WriteLn( Valid( '2'    ) );  { TRUE  }
  2164.  
  2165. END;
  2166.  
  2167.  
  2168. ──────────────────────────────────────────────────────────────────────────────
  2169.  
  2170.  
  2171. [FUNCTION]
  2172.  
  2173. Function  ValidHexWord(              S         : STRING  ) : BOOLEAN;
  2174.  
  2175. [PARAMETERS]
  2176.  
  2177. S           String representing a Word value in hex
  2178.  
  2179. [RETURNS]
  2180.  
  2181. Whether that string did represent a word value in hex
  2182.  
  2183. [DESCRIPTION]
  2184.  
  2185. Returns whether or not the given String represents a Valid
  2186. Word in Hexadecimal format.
  2187.  
  2188. [SEE-ALSO]
  2189.  
  2190. ValidByte
  2191. ValidInt
  2192. ValidLong
  2193. ValidFloat
  2194. ValidSci
  2195. ValidHexByte
  2196. ValidHex
  2197.  
  2198. [EXAMPLE]
  2199.  
  2200. BEGIN
  2201.  
  2202.   WriteLn( ValidHexWord( '1A2B'  ) );  { TRUE  }
  2203.   WriteLn( ValidHexWord( 'FFFf'  ) );  { TRUE  }
  2204.   WriteLn( ValidHexWord( '12345' ) );  { FALSE }
  2205.   WriteLn( ValidHexWord( 'zyxw'  ) );  { FALSE }
  2206.   WriteLn( ValidHexWord( '12'    ) );  { TRUE  }
  2207.  
  2208. END;
  2209.  
  2210.  
  2211. ──────────────────────────────────────────────────────────────────────────────
  2212.  
  2213.  
  2214. [FUNCTION]
  2215.  
  2216. Function  ValidHex(                  S         : STRING  ) : BOOLEAN;
  2217.  
  2218. [PARAMETERS]
  2219.  
  2220. S           String representing a Word value in hex
  2221.  
  2222. [RETURNS]
  2223.  
  2224. Whether that string did represent a word value in hex
  2225.  
  2226. [DESCRIPTION]
  2227.  
  2228. Returns whether or not the given String represents a Valid
  2229. value in Hexadecimal format.  This function doesn't consider
  2230. length to be of consideration.  It simply checks that throughout
  2231. the entire length of the string, every character is within the
  2232. valid range of a Hex character.
  2233.  
  2234. [SEE-ALSO]
  2235.  
  2236. ValidByte
  2237. ValidInt
  2238. ValidLong
  2239. ValidFloat
  2240. ValidSci
  2241. ValidHexByte
  2242. ValidHex
  2243.  
  2244. [EXAMPLE]
  2245.  
  2246. BEGIN
  2247.  
  2248.   WriteLn( ValidHex( '1D'      ) );  { TRUE  }
  2249.   WriteLn( ValidHex( '15DF'    ) );  { TRUE  }
  2250.   WriteLn( ValidHex( 'zwyvx'   ) );  { FALSE }
  2251.   WriteLn( ValidHex( '153FD85' ) );  { TRUE  }
  2252.  
  2253. END;
  2254.  
  2255.  
  2256. ──────────────────────────────────────────────────────────────────────────────
  2257.  
  2258.  
  2259. [FUNCTION]
  2260.  
  2261. Function  IsAlpha(                   C         : CHAR    ) : BOOLEAN;
  2262.  
  2263. [PARAMETERS]
  2264.  
  2265. Source character to be tested.
  2266.  
  2267. [RETURNS]
  2268.  
  2269. Was this character an Alphabetic Character?
  2270.  
  2271. [DESCRIPTION]
  2272.  
  2273. Test char to ensure that it is an alphabetic char and returns the result.
  2274. An alphabetic char is defined as... all alphabetic chars (both upper
  2275. and lower case) including foreign language inflections.
  2276.  
  2277. [SEE-ALSO]
  2278.  
  2279. IsNum
  2280. IsAlphaNum
  2281. IsUpCase
  2282. IsLoCase
  2283. IsGrammar
  2284. IsCtrl
  2285. IsBorder
  2286. IsLang
  2287. IsSymbol
  2288.  
  2289. [EXAMPLE]
  2290.  
  2291. BEGIN
  2292.  
  2293.   WriteLn( IsAlpha( 'a' ) );  { TRUE  }
  2294.   WriteLn( IsAlpha( 'A' ) );  { TRUE  }
  2295.   WriteLn( IsAlpha( '8' ) );  { FALSE }
  2296.   WriteLn( IsAlpha( '-' ) );  { FALSE }
  2297.   WriteLn( IsAlpha( 'ë' ) );  { TRUE  - Note: It includes Foreign Text! }
  2298.   WriteLn( IsAlpha( 'Æ' ) );  { TRUE  }
  2299.  
  2300. END;
  2301.  
  2302.  
  2303. ──────────────────────────────────────────────────────────────────────────────
  2304.  
  2305.  
  2306. [FUNCTION]
  2307.  
  2308. Function  IsNum(                     C         : CHAR    ) : BOOLEAN;
  2309.  
  2310. [PARAMETERS]
  2311.  
  2312. C           Source Character to be tested.
  2313.  
  2314. [RETURNS]
  2315.  
  2316. Whether that character did represent a numeric char
  2317.  
  2318. [DESCRIPTION]
  2319.  
  2320. Test char to ensure that it is a numeric char and returns the result.
  2321. A numeric char is defined as... all chars from ASCII xx to ASCII xx
  2322.  
  2323. [SEE-ALSO]
  2324.  
  2325. IsAlpha
  2326. IsAlphaNum
  2327. IsUpCase
  2328. IsLoCase
  2329. IsGrammar
  2330. IsCtrl
  2331. IsBorder
  2332. IsLang
  2333. IsSymbol
  2334.  
  2335. [EXAMPLE]
  2336.  
  2337. BEGIN
  2338.  
  2339.   WriteLn( IsNum( '4' ) );  { TRUE  }
  2340.   WriteLn( IsNum( 'K' ) );  { FALSE }
  2341.   WriteLn( IsNum( '#' ) );  { FALSE }
  2342.  
  2343. END;
  2344.  
  2345.  
  2346. ──────────────────────────────────────────────────────────────────────────────
  2347.  
  2348.  
  2349. [FUNCTION]
  2350.  
  2351. Function  IsAlphaNum(                C         : CHAR    ) : BOOLEAN;
  2352.  
  2353. [PARAMETERS]
  2354.  
  2355. C           Source Character character to be tested
  2356.  
  2357. [RETURNS]
  2358.  
  2359. Whether that character did represent an alpha-numeric char
  2360.  
  2361. [DESCRIPTION]
  2362.  
  2363. Tests char to ensure that it is alpha-numeric and returns result.
  2364. An alpha-numeric char is defined as... all numeric and alphbetic
  2365. chars (both upper and lower case) including foreign language inflections.
  2366.  
  2367. [SEE-ALSO]
  2368.  
  2369. IsAlpha
  2370. IsNum
  2371. IsUpCase
  2372. IsLoCase
  2373. IsGrammar
  2374. IsCtrl
  2375. IsBorder
  2376. IsLang
  2377. IsSymbol
  2378.  
  2379. [EXAMPLE]
  2380.  
  2381. BEGIN
  2382.  
  2383.   WriteLn( IsAlphaNum( 'a' ) );  { TRUE  }
  2384.   WriteLn( IsAlphaNum( 'A' ) );  { TRUE  }
  2385.   WriteLn( IsAlphaNum( ' ' ) );  { FALSE }
  2386.   WriteLn( IsAlphaNum( '4' ) );  { TRUE  }
  2387.   WriteLn( IsAlphaNum( '&' ) );  { FALSE }
  2388.   WriteLn( IsAlphaNum( 'ü' ) );  { TRUE  }
  2389.  
  2390. END;
  2391.  
  2392.  
  2393. ──────────────────────────────────────────────────────────────────────────────
  2394.  
  2395.  
  2396. [FUNCTION]
  2397.  
  2398. Function  IsUpCase(                  C         : CHAR    ) : BOOLEAN;
  2399.  
  2400. [PARAMETERS]
  2401.  
  2402. C           Source Character to be tested
  2403.  
  2404. [RETURNS]
  2405.  
  2406. Whether that character did represent an upper case char of any language
  2407.  
  2408. [DESCRIPTION]
  2409.  
  2410. Tests char to ensure that it is an upper case char (whether English or
  2411. Foreign Inflection) and returns result.
  2412.  
  2413. [SEE-ALSO]
  2414.  
  2415. IsAlpha
  2416. IsNum
  2417. IsAlphaNum
  2418. IsLoCase
  2419. IsGrammar
  2420. IsCtrl
  2421. IsBorder
  2422. IsLang
  2423. IsSymbol
  2424.  
  2425. [EXAMPLE]
  2426.  
  2427. BEGIN
  2428.  
  2429.   WriteLn( IsUpCase( 'A' ) );  { TRUE  }
  2430.   WriteLn( IsUpCase( 'a' ) );  { FALSE }
  2431.   WriteLn( IsUpCase( 'ü' ) );  { FALSE }
  2432.   WriteLn( IsUpCase( 'Æ' ) );  { TRUE  }
  2433.   WriteLn( IsUpCase( '%' ) );  { FALSE }
  2434.   WriteLn( IsUpCase( '3' ) );  { FALSE }
  2435.  
  2436. END;
  2437.  
  2438.  
  2439. ──────────────────────────────────────────────────────────────────────────────
  2440.  
  2441.  
  2442. [FUNCTION]
  2443.  
  2444. Function  IsLoCase(                  C         : CHAR    ) : BOOLEAN;
  2445.  
  2446. [PARAMETERS]
  2447.  
  2448. C           Source Character to be tested
  2449.  
  2450. [RETURNS]
  2451.  
  2452. Whether that character did represent a lower case char in any language.
  2453.  
  2454. [DESCRIPTION]
  2455.  
  2456. Tests char to ensure that it is a lower case char (whether English or
  2457. Foreign Imflection) and returns result.
  2458.  
  2459. [SEE-ALSO]
  2460.  
  2461. IsAlpha
  2462. IsNum
  2463. IsAlphaNum
  2464. IsUpCase
  2465. IsGrammar
  2466. IsCtrl
  2467. IsBorder
  2468. IsLang
  2469. IsSymbol
  2470.  
  2471. [EXAMPLE]
  2472.  
  2473. BEGIN
  2474.  
  2475.   WriteLn( IsUpCase( 'A' ) );  { FALSE }
  2476.   WriteLn( IsUpCase( 'a' ) );  { TRUE  }
  2477.   WriteLn( IsUpCase( 'ü' ) );  { TRUE  }
  2478.   WriteLn( IsUpCase( 'Æ' ) );  { FALSE }
  2479.   WriteLn( IsUpCase( '%' ) );  { FALSE }
  2480.   WriteLn( IsUpCase( '3' ) );  { FALSE }
  2481.  
  2482. END;
  2483.  
  2484.  
  2485. ──────────────────────────────────────────────────────────────────────────────
  2486.  
  2487.  
  2488. [FUNCTION]
  2489.  
  2490. Function  IsGrammar(                 C         : CHAR    ) : BOOLEAN;
  2491.  
  2492. [PARAMETERS]
  2493.  
  2494. C           Source Character to be tested
  2495.  
  2496. [RETURNS]
  2497.  
  2498. Whether that character did represent a grammar char
  2499.  
  2500. [DESCRIPTION]
  2501.  
  2502. Tests char to ensure that it is a grammar char and returns result.
  2503. This includes all standard grammar symbols as well as all math and
  2504. currency symbols.
  2505.  
  2506. [SEE-ALSO]
  2507.  
  2508. IsAlpha
  2509. IsNum
  2510. IsAlphaNum
  2511. IsUpCase
  2512. IsLoCase
  2513. IsCtrl
  2514. IsBorder
  2515. IsLang
  2516. IsSymbol
  2517.  
  2518. [EXAMPLE]
  2519.  
  2520. BEGIN
  2521.  
  2522.   WriteLn( IsGrammar( '.' ) );  { TRUE  }
  2523.   WriteLn( IsGrammar( '!' ) );  { TRUE  }
  2524.   WriteLn( IsGrammar( 'd' ) );  { FALSE }
  2525.   WriteLn( IsGrammar( '6' ) );  { FALSE }
  2526.   WriteLn( IsGrammar( '&' ) );  { TRUE  }
  2527.   WriteLn( IsGrammar( '/' ) );  { TRUE  }
  2528.  
  2529. END;
  2530.  
  2531.  
  2532. ──────────────────────────────────────────────────────────────────────────────
  2533.  
  2534.  
  2535. [FUNCTION]
  2536.  
  2537. Function  IsCtrl(                    C         : CHAR    ) : BOOLEAN;
  2538.  
  2539. [PARAMETERS]
  2540.  
  2541. C           Source Character to be tested.
  2542.  
  2543. [RETURNS]
  2544.  
  2545. Whether that character did represent a control character
  2546.  
  2547. [DESCRIPTION]
  2548.  
  2549. Tests char to ensure that it is a control char and returns the result.
  2550. A control char is defined as all chars below the ASCII value of 32.
  2551.  
  2552. [SEE-ALSO]
  2553.  
  2554. IsAlpha
  2555. IsNum
  2556. IsAlphaNum
  2557. IsUpCase
  2558. IsLoCase
  2559. IsGrammar
  2560. IsBorder
  2561. IsLang
  2562. IsSymbol
  2563.  
  2564. [EXAMPLE]
  2565.  
  2566. BEGIN
  2567.  
  2568.   WriteLn( IsCtrl( #13 ) );  { TRUE  }
  2569.   WriteLn( IsCtrl( #26 ) );  { TRUE  }
  2570.   WriteLn( IsCtrl( #32 ) );  { FALSE }
  2571.   WriteLn( IsCtrl( #97 ) );  { FALSE }
  2572.  
  2573. END;
  2574.  
  2575.  
  2576. ──────────────────────────────────────────────────────────────────────────────
  2577.  
  2578.  
  2579. [FUNCTION]
  2580.  
  2581. Function  IsBorder(                  C         : CHAR    ) : BOOLEAN;
  2582.  
  2583. [PARAMETERS]
  2584.  
  2585. C           Source Character to be tested.
  2586.  
  2587. [RETURNS]
  2588.  
  2589. Whether that character did represent a border character.
  2590.  
  2591. [DESCRIPTION]
  2592.  
  2593. Tests char to ensure that it is a border char and returns the result.
  2594. A border char is defined as all line drawing chars as well as
  2595. non-graphic text chars (vertical bar,plus, and dash) in addition
  2596. to solid boxes.
  2597.  
  2598. Except where the ASCII value is below 128, these chars are represented
  2599. as those that extend and touch the adjacent chars.
  2600.  
  2601. [SEE-ALSO]
  2602.  
  2603. IsAlpha
  2604. IsNum
  2605. IsAlphaNum
  2606. IsUpCase
  2607. IsLoCase
  2608. IsGrammar
  2609. IsCtrl
  2610. IsLang
  2611. IsSymbol
  2612.  
  2613. [EXAMPLE]
  2614.  
  2615. BEGIN
  2616.  
  2617.   WriteLn( IsBorder( '╔' ) );  { TRUE  }
  2618.   WriteLn( IsBorder( '┼' ) );  { TRUE  }
  2619.   WriteLn( IsBorder( 'a' ) );  { FALSE }
  2620.   WriteLn( IsBorder( '7' ) );  { FALSE }
  2621.   WriteLn( IsBorder( '█' ) );  { TRUE  }
  2622.   WriteLn( IsBorder( '&' ) );  { FALSE }
  2623.   WriteLn( IsBorder( '-' ) );  { TRUE  - Text Mode Borders }
  2624.   WriteLn( IsBorder( '|' ) );  { TRUE  }
  2625.   WriteLn( IsBorder( '+' ) );  { TRUE  }
  2626.  
  2627. END;
  2628.  
  2629.  
  2630. ──────────────────────────────────────────────────────────────────────────────
  2631.  
  2632.  
  2633. [FUNCTION]
  2634.  
  2635. Function  IsLang(                    C         : CHAR    ) : BOOLEAN;
  2636.  
  2637. [PARAMETERS]
  2638.  
  2639. C           Source Character to be tested.
  2640.  
  2641. [RETURNS]
  2642.  
  2643. Whether that character did represent a Foreign Language character.
  2644.  
  2645. [DESCRIPTION]
  2646.  
  2647. Test char to ensure that it is a language char and returns the result.
  2648. A language char is defined as all Foreign Language Alphbetic chars
  2649. (essentially those alpha chars containing foreign language inflections)
  2650.  
  2651. [SEE-ALSO]
  2652.  
  2653. IsAlpha
  2654. IsNum
  2655. IsAlphaNum
  2656. IsUpCase
  2657. IsLoCase
  2658. IsGrammar
  2659. IsCtrl
  2660. IsBorder
  2661. IsSymbol
  2662.  
  2663. [EXAMPLE]
  2664.  
  2665. BEGIN
  2666.  
  2667.   WriteLn( IsLang( 'Ä' ) );  { TRUE  }
  2668.   WriteLn( IsLang( 'ü' ) );  { TRUE  }
  2669.   WriteLn( IsLang( 'a' ) );  { FALSE }
  2670.   WriteLn( IsLang( 'Q' ) );  { FALSE }
  2671.   WriteLn( IsLang( '6' ) );  { FALSE }
  2672.   WriteLn( IsLang( '&' ) );  { FALSE }
  2673.   WriteLn( IsLang( '╔' ) );  { FALSE }
  2674.  
  2675. END;
  2676.  
  2677.  
  2678. ──────────────────────────────────────────────────────────────────────────────
  2679.  
  2680.  
  2681. [FUNCTION]
  2682.  
  2683. Function  IsSymbol(                  C         : CHAR    ) : BOOLEAN;
  2684.  
  2685. [PARAMETERS]
  2686.  
  2687. C           Character representing a symbol char
  2688.  
  2689. [RETURNS]
  2690.  
  2691. Whether that character did represent a symbol char
  2692.  
  2693. [DESCRIPTION]
  2694.  
  2695. Tests char to ensure that it is a symbol char and returns the result.
  2696. A border char is defined as all chars excluding the following:
  2697. Numeric, Alphabetic (both upper and lower case), all grammar chars,
  2698. all border chars, all control characters, and all foreign language
  2699. chars.  Basically all misc chars not used by any of the previous tests
  2700. and definitions.
  2701.  
  2702. [SEE-ALSO]
  2703.  
  2704. IsAlpha
  2705. IsNum
  2706. IsAlphaNum
  2707. IsUpCase
  2708. IsLoCase
  2709. IsGrammar
  2710. IsCtrl
  2711. IsBorder
  2712. IsLang
  2713.  
  2714. [EXAMPLE]
  2715.  
  2716. BEGIN
  2717.  
  2718.   WriteLn( IsSymbol( '≤' ) );  { TRUE  }
  2719.   WriteLn( IsSymbol( 'A' ) );  { FALSE }
  2720.   WriteLn( IsSymbol( '6' ) );  { FALSE }
  2721.   WriteLn( IsSymbol( '#' ) );  { FALSE }
  2722.   WriteLn( IsSymbol( '√' ) );  { TRUE  }
  2723.   WriteLn( IsSymbol( '╔' ) );  { FALSE }
  2724.   WriteLn( IsSymbol( '≈' ) );  { TRUE  }
  2725.  
  2726. END;
  2727.  
  2728.  
  2729. ──────────────────────────────────────────────────────────────────────────────
  2730.  
  2731.  
  2732. [FUNCTION]
  2733.  
  2734. Function  IntToStr(                  L         : LONGINT ) : STRING;
  2735.  
  2736. [PARAMETERS]
  2737.  
  2738. L           Longint value to convert to string
  2739.  
  2740. [RETURNS]
  2741.  
  2742. String representation of integer value
  2743.  
  2744. [DESCRIPTION]
  2745.  
  2746. Converts an integer value into a string
  2747.  
  2748. [SEE-ALSO]
  2749.  
  2750. StrToInt
  2751.  
  2752. [EXAMPLE]
  2753.  
  2754. VAR
  2755.   S : STRING;
  2756.  
  2757. BEGIN
  2758.  
  2759.   S := IntToStr( 12345 );
  2760.  
  2761.   { S = '12345' }
  2762.  
  2763. END;
  2764.  
  2765.  
  2766. ──────────────────────────────────────────────────────────────────────────────
  2767.  
  2768.  
  2769. [FUNCTION]
  2770.  
  2771. Function  StrToInt(                  S         : STRING  ) : LONGINT;
  2772.  
  2773. [PARAMETERS]
  2774.  
  2775. S           String to convert to integer value
  2776.  
  2777. [RETURNS]
  2778.  
  2779. Integer representation of string.  If Error then result is Zero.
  2780.  
  2781. [DESCRIPTION]
  2782.  
  2783. Converts a string into an integer value.
  2784.  
  2785. [SEE-ALSO]
  2786.  
  2787. IntToStr
  2788.  
  2789. [EXAMPLE]
  2790.  
  2791. VAR
  2792.   L : LONGINT;
  2793.  
  2794. BEGIN
  2795.  
  2796.   L := StrToInt( '4312' );
  2797.  
  2798.   { L = 4312 }
  2799.  
  2800. END;
  2801.  
  2802.  
  2803. ──────────────────────────────────────────────────────────────────────────────
  2804.  
  2805.  
  2806. [FUNCTION]
  2807.  
  2808. Function  RealToStr(                 R         : REAL;
  2809.                                      Field     : INTEGER;
  2810.                                      Decimals  : INTEGER  ) : STRING;
  2811.  
  2812. [PARAMETERS]
  2813.  
  2814. R           Floating point value to convert to string
  2815. Field       Desired final width of string
  2816. Decimals    Desired number of decimal places to use in string
  2817.  
  2818. [RETURNS]
  2819.  
  2820. String representation of Floating point value
  2821.  
  2822. [DESCRIPTION]
  2823.  
  2824. Converts a floating point value into a string using the given string
  2825. width and decimal places.
  2826.  
  2827. [SEE-ALSO]
  2828.  
  2829. StrToReal
  2830.  
  2831. [EXAMPLE]
  2832.  
  2833. VAR
  2834.   S : STRING;
  2835.  
  2836. BEGIN
  2837.  
  2838.   S := RealToStr( 1.5, 8, 4 );
  2839.  
  2840.   { S = '  1.5000' }
  2841.  
  2842. END;
  2843.  
  2844.  
  2845. ──────────────────────────────────────────────────────────────────────────────
  2846.  
  2847.  
  2848. [FUNCTION]
  2849.  
  2850. Function  StrToReal(                 S         : STRING  ) : REAL;
  2851.  
  2852. [PARAMETERS]
  2853.  
  2854. S           String to convert to a floating point value
  2855.  
  2856. [RETURNS]
  2857.  
  2858. Floating point representation of string.
  2859.  
  2860. [DESCRIPTION]
  2861.  
  2862. Converts a string into a floating point value.
  2863. If Error then result is Zero.
  2864.  
  2865. NOTE: This Function does NOT take care of Leading or Trailing
  2866. Spaces or other Symbols.  This MUST be taken care of by the
  2867. caller.  All data must be prepared for immediate use.
  2868.  
  2869. [SEE-ALSO]
  2870.  
  2871. RealToStr
  2872.  
  2873. [EXAMPLE]
  2874.  
  2875. VAR
  2876.   R : REAL;
  2877.  
  2878. BEGIN
  2879.  
  2880.   R := StrToReal( '1.5' );
  2881.  
  2882.   { R = 1.5 }
  2883.  
  2884. END;
  2885.  
  2886.  
  2887. ──────────────────────────────────────────────────────────────────────────────
  2888.  
  2889.  
  2890. [FUNCTION]
  2891.  
  2892. Function  SciToStr(                  R         : REAL    ) : STRING;
  2893.  
  2894. [PARAMETERS]
  2895.  
  2896. S           Floating point value to convert to string in scientific notation
  2897.  
  2898. [RETURNS]
  2899.  
  2900. String representation of floating point value using scientific notation
  2901.  
  2902. [DESCRIPTION]
  2903.  
  2904. Converts a floating point value into a string using scientific notation.
  2905.  
  2906. [SEE-ALSO]
  2907.  
  2908. StrToSci
  2909.  
  2910. [EXAMPLE]
  2911.  
  2912. VAR
  2913.   R : REAL;
  2914.   S : STRING;
  2915.  
  2916. BEGIN
  2917.  
  2918.   R := 1.25E2;  { 125 }
  2919.   S := SciToStr( R );
  2920.  
  2921.   { S = '1.25E2' }
  2922.  
  2923. END;
  2924.  
  2925.  
  2926. ──────────────────────────────────────────────────────────────────────────────
  2927.  
  2928.  
  2929. [FUNCTION]
  2930.  
  2931. Function  StrToSci(                  S         : STRING  ) : REAL;
  2932.  
  2933. [PARAMETERS]
  2934.  
  2935. S           String in scientific notation to convert to floating point value
  2936.  
  2937. [RETURNS]
  2938.  
  2939. Floating point representation of string.  If Error then result is Zero.
  2940.  
  2941. [DESCRIPTION]
  2942.  
  2943. Converts string of scientific notatation value to a floating point value.
  2944. If Error then floating point is Zero.
  2945.  
  2946. [SEE-ALSO]
  2947.  
  2948. SciToStr
  2949.  
  2950. [EXAMPLE]
  2951.  
  2952. VAR
  2953.   R : REAL;
  2954.  
  2955. BEGIN
  2956.  
  2957.   R := StrToSci( '1.25E2' );
  2958.  
  2959.   { R = 1.25E2 or 125 }
  2960.  
  2961. END;
  2962.  
  2963.  
  2964. ──────────────────────────────────────────────────────────────────────────────
  2965.  
  2966.  
  2967. [FUNCTION]
  2968.  
  2969. Function  IntToText(                 L         : LONGINT ) : ST80;
  2970.  
  2971. [PARAMETERS]
  2972.  
  2973. L           Integer value to convert to text string
  2974.  
  2975. [RETURNS]
  2976.  
  2977. Text String representation of integer value.
  2978.  
  2979. [DESCRIPTION]
  2980.  
  2981. Converts integer value into text form.  Handles all values into the
  2982. Billions.  The limiting factor is that the returned string is only
  2983. 80 chars long and thus will clip any further text.
  2984.  
  2985. [SEE-ALSO]
  2986.  
  2987.  
  2988. [EXAMPLE]
  2989.  
  2990. VAR
  2991.   S : STRING;
  2992.  
  2993. BEGIN
  2994.  
  2995.   S := IntToText( 10 );
  2996.   { S now equals "Ten" }
  2997.  
  2998.   S := IntToText( 1,234,000 );
  2999.  
  3000.   { S equals "One Million, Two Hundred Thirty Four Thousand" }
  3001.  
  3002.  
  3003. ──────────────────────────────────────────────────────────────────────────────
  3004.  
  3005.  
  3006. [FUNCTION]
  3007.  
  3008. Function  LongToDollars(             L         : LONGINT ) : REAL;
  3009.  
  3010. [PARAMETERS]
  3011.  
  3012. L           Currency Value in Cents
  3013.  
  3014. [RETURNS]
  3015.  
  3016. Currency Value in Dollars.  (Pennies now represented as fractions)
  3017.  
  3018. [DESCRIPTION]
  3019.  
  3020. Converts an integer penny amount into a floating point dollar amount
  3021.  
  3022. [SEE-ALSO]
  3023.  
  3024. DollarsToLong
  3025.  
  3026. [EXAMPLE]
  3027.  
  3028. VAR
  3029.   R : REAL;
  3030.  
  3031. BEGIN
  3032.  
  3033.   R := LongToDollars( 12500 );
  3034.  
  3035.   { R = 125.00 }
  3036.  
  3037. END;
  3038.  
  3039.  
  3040. ──────────────────────────────────────────────────────────────────────────────
  3041.  
  3042.  
  3043. [FUNCTION]
  3044.  
  3045. Function  DollarsToLong(             R         : REAL    ) : LONGINT;
  3046.  
  3047. [PARAMETERS]
  3048.  
  3049. R           Currency Value in Dollars
  3050.  
  3051. [RETURNS]
  3052.  
  3053. Currency Value in Cents.  (Dollars now represented as 100 Pennies)
  3054.  
  3055. [DESCRIPTION]
  3056.  
  3057. Converts a floating point dollar amount into an integer penny amount
  3058.  
  3059. [SEE-ALSO]
  3060.  
  3061. LongToDollars
  3062.  
  3063. [EXAMPLE]
  3064.  
  3065. VAR
  3066.   L : LONGINT;
  3067.  
  3068. BEGIN
  3069.  
  3070.   L := DollarsToLong( 125.00 );
  3071.  
  3072.   { L = 12500 }
  3073.  
  3074. END;
  3075.  
  3076.  
  3077. ──────────────────────────────────────────────────────────────────────────────
  3078.  
  3079.  
  3080. [FUNCTION]
  3081.  
  3082. Procedure StrToArray(                S         : STRING;
  3083.                                  Var TheArray            );
  3084.  
  3085. [PARAMETERS]
  3086.  
  3087. S           Pascal String to convert to an array
  3088. TheArray    VAR working array to return results in
  3089.  
  3090. [RETURNS]
  3091.  
  3092. Function : None
  3093. (Var     : [TheArray] The array of characters so stored)
  3094.  
  3095. [DESCRIPTION]
  3096.  
  3097. This function converts a PASCAL String into an Array of Characters.
  3098. (NOTE: The Array is NOT Zero Terminated or length denoted by any means!)
  3099.  
  3100. [SEE-ALSO]
  3101.  
  3102. ArrayToStr
  3103.  
  3104. [EXAMPLE]
  3105.  
  3106. TYPE
  3107.   TArr = ARRAY[1..10] of CHAR;
  3108.  
  3109. VAR
  3110.   S   : STRING;
  3111.   Arr : TArr;
  3112.  
  3113. BEGIN
  3114.  
  3115.   S := 'Hello';
  3116.   StrToArray( S, Arr );
  3117.  
  3118.   { Arr[1]='H', .. ,Arr[5]='o' }
  3119.   { Data Now in Array Format   }
  3120.  
  3121. END;
  3122.  
  3123.  
  3124. ──────────────────────────────────────────────────────────────────────────────
  3125.  
  3126.  
  3127. [FUNCTION]
  3128.  
  3129. Function  ArrayToStr(            Var TheArray;
  3130.                                      Len       : BYTE    ) : STRING;
  3131.  
  3132. [PARAMETERS]
  3133.  
  3134. TheArray    VAR Address of the source array to convert to a string
  3135. Len         Desired final string length
  3136.  
  3137. [RETURNS]
  3138.  
  3139. Pascal String created from array
  3140.  
  3141. [DESCRIPTION]
  3142.  
  3143. This function converts an Array of Characters into a PASCAL String.
  3144. (NOTE: The input Array need not be terminated in any way, but will
  3145. be exactly duplicated up to the length "Len" - even if beyond the
  3146. Array!)
  3147.  
  3148. [SEE-ALSO]
  3149.  
  3150. StrToArray
  3151.  
  3152. [EXAMPLE]
  3153.  
  3154. TYPE
  3155.   TArr = ARRAY[1..10] of CHAR;
  3156.  
  3157. VAR
  3158.   S   : STRING;
  3159.   Arr : TArr;
  3160.  
  3161. BEGIN
  3162.  
  3163.   Arr[1] := 'Y';
  3164.   Arr[2] := 'e';
  3165.   Arr[3] := 's';
  3166.  
  3167.   S := ArrayToStr( Arr, 3 );
  3168.  
  3169.   { S = 'Yes' }
  3170.  
  3171. END;
  3172.  
  3173.  
  3174. ──────────────────────────────────────────────────────────────────────────────
  3175.  
  3176.  
  3177. [FUNCTION]
  3178.  
  3179. Procedure StrToAsciiZ(               S         : STRING;
  3180.                                  Var AsciiZStr           );
  3181.  
  3182. [PARAMETERS]
  3183.  
  3184. S           Pascal String to convert into an AsciiZ String
  3185. AsciiZStr   VAR working array ton return AsciiZ string in
  3186.  
  3187. [RETURNS]
  3188.  
  3189. Function : None
  3190. (Var     : [AsciiZStr] The new ASCIIZ String)
  3191.  
  3192. [DESCRIPTION]
  3193.  
  3194. This Procedure converts a PASCAL String into an ASCIIZ String (a null-
  3195. terminated character array).  This is particularly useful when
  3196. converting Pascal Strings to C Strings.
  3197.  
  3198. [SEE-ALSO]
  3199.  
  3200. AsciiZtoStr
  3201.  
  3202. [EXAMPLE]
  3203.  
  3204. TYPE
  3205.   TArr = ARRAY[1..10] of CHAR;
  3206.  
  3207. VAR
  3208.   S   : STRING;
  3209.   Arr : TArr;
  3210.  
  3211. BEGIN
  3212.  
  3213.   S := 'Yes';
  3214.   StrToAsciiZ( S, Arr );
  3215.  
  3216.   { Arr[1]='Y' }
  3217.   { Arr[2]='e' }
  3218.   { Arr[3]='s' }
  3219.   { Arr[4]=#0  - NULL Terminated! }
  3220.  
  3221. END;
  3222.  
  3223.  
  3224. ──────────────────────────────────────────────────────────────────────────────
  3225.  
  3226.  
  3227. [FUNCTION]
  3228.  
  3229. Function  AsciiZtoStr(           Var AsciiZStr           ) : STRING;
  3230.  
  3231. [PARAMETERS]
  3232.  
  3233. AsciiZStr   VAR address of source AsciiZ string to convert to a string
  3234.  
  3235. [RETURNS]
  3236.  
  3237. Pascal String created from AsciiZ source string
  3238.  
  3239. [DESCRIPTION]
  3240.  
  3241. This function converts an ASCIIZ String (a null-terminated character
  3242. array) into a PASCAL String.  This is particularly useful when
  3243. converting a C String to a Pascal String.
  3244.  
  3245. [SEE-ALSO]
  3246.  
  3247. StrToAsciiZ
  3248.  
  3249. [EXAMPLE]
  3250.  
  3251. TYPE
  3252.   TArr = ARRAY[1..10] of CHAR;
  3253.  
  3254. VAR
  3255.   S   : STRING;
  3256.   Arr : TArr;
  3257.  
  3258. BEGIN
  3259.  
  3260.   Arr[1] := 'Y';
  3261.   Arr[2] := 'e';
  3262.   Arr[3] := 's';
  3263.   Arr[4] := #0;
  3264.  
  3265.   S := AsciiZtoStr( Arr );
  3266.  
  3267.   { S = 'Yes' }
  3268.  
  3269. END;
  3270.  
  3271.  
  3272. ──────────────────────────────────────────────────────────────────────────────
  3273.  
  3274.  
  3275. [FUNCTION]
  3276.  
  3277. Function  CharToHex(                 C         : SHORTINT) : ST80;
  3278.  
  3279. [PARAMETERS]
  3280.  
  3281. C           Signed Byte (SHORTINT) value to convert to a hex string
  3282.  
  3283. [RETURNS]
  3284.  
  3285. Hex string representation of signed byte value
  3286.  
  3287. [DESCRIPTION]
  3288.  
  3289. Converts a Signed Byte (Shortint) value into a hexadecimal string
  3290.  
  3291. [SEE-ALSO]
  3292.  
  3293. ByteToHex
  3294. IntToHex
  3295. WordToHex
  3296. PtrToHex
  3297. LongToHex
  3298. HexToChar
  3299. HexToByte
  3300. HexToInt
  3301. HexToWord
  3302. HexToLong
  3303.  
  3304. [EXAMPLE]
  3305.  
  3306. VAR
  3307.   S : STRING;
  3308.  
  3309. BEGIN
  3310.  
  3311.   S := CharToHex( #32 );
  3312.  
  3313.   { S = '20' (Hex of 32) }
  3314.  
  3315. END;
  3316.  
  3317.  
  3318. ──────────────────────────────────────────────────────────────────────────────
  3319.  
  3320.  
  3321. [FUNCTION]
  3322.  
  3323. Function  ByteToHex(                 B         : BYTE    ) : ST80;
  3324.  
  3325. [PARAMETERS]
  3326.  
  3327. B           Unsigned Byte value to convert to a hex string
  3328.  
  3329. [RETURNS]
  3330.  
  3331. Hex string representation of byte value
  3332.  
  3333. [DESCRIPTION]
  3334.  
  3335. Converts an Unsigned Byte Value into a Hexadecimal String
  3336.  
  3337. [SEE-ALSO]
  3338.  
  3339. CharToHex
  3340. IntToHex
  3341. WordToHex
  3342. PtrToHex
  3343. LongToHex
  3344. HexToChar
  3345. HexToByte
  3346. HexToInt
  3347. HexToWord
  3348. HexToLong
  3349.  
  3350. [EXAMPLE]
  3351.  
  3352. VAR
  3353.   S : STRING;
  3354.  
  3355. BEGIN
  3356.  
  3357.   S := ByteToHex( #32 );
  3358.  
  3359.   { S = '20' (Hex of 32) }
  3360.  
  3361. END;
  3362.  
  3363.  
  3364. ──────────────────────────────────────────────────────────────────────────────
  3365.  
  3366.  
  3367. [FUNCTION]
  3368.  
  3369. Function  IntToHex(                  I         : INTEGER ) : ST80;
  3370.  
  3371. [PARAMETERS]
  3372.  
  3373. I           Signed Word (INTEGER) value to convert to a hex string
  3374.  
  3375. [RETURNS]
  3376.  
  3377. Hex string representation of signed word value
  3378.  
  3379. [DESCRIPTION]
  3380.  
  3381. Converts a Signed Word (INTEGER) value into a hexadecimal string
  3382.  
  3383. [SEE-ALSO]
  3384.  
  3385. CharToHex
  3386. ByteToHex
  3387. WordToHex
  3388. PtrToHex
  3389. LongToHex
  3390. HexToChar
  3391. HexToByte
  3392. HexToInt
  3393. HexToWord
  3394. HexToLong
  3395.  
  3396. [EXAMPLE]
  3397.  
  3398. VAR
  3399.   S : STRING;
  3400.  
  3401. BEGIN
  3402.  
  3403.   S := IntToHex( -32000 );
  3404.  
  3405.   { S = '8300' }
  3406.  
  3407. END;
  3408.  
  3409.  
  3410. ──────────────────────────────────────────────────────────────────────────────
  3411.  
  3412.  
  3413. [FUNCTION]
  3414.  
  3415. Function  WordToHex(                 W         : WORD    ) : ST80;
  3416.  
  3417. [PARAMETERS]
  3418.  
  3419. W           Unsigned Word to convert to a hex string
  3420.  
  3421. [RETURNS]
  3422.  
  3423. Hex string representation of word value
  3424.  
  3425. [DESCRIPTION]
  3426.  
  3427. Converts an Unsigned Word into a hexadecimal string
  3428.  
  3429. [SEE-ALSO]
  3430.  
  3431. CharToHex
  3432. ByteToHex
  3433. IntToHex
  3434. PtrToHex
  3435. LongToHex
  3436. HexToChar
  3437. HexToByte
  3438. HexToInt
  3439. HexToWord
  3440. HexToLong
  3441.  
  3442. [EXAMPLE]
  3443.  
  3444. VAR
  3445.   S : STRING;
  3446.  
  3447. BEGIN
  3448.  
  3449.   S := WordToHex( 50000 );
  3450.  
  3451.   { S = 'C350' }
  3452.  
  3453. END;
  3454.  
  3455.  
  3456. ──────────────────────────────────────────────────────────────────────────────
  3457.  
  3458.  
  3459. [FUNCTION]
  3460.  
  3461. Function  PtrToHex(                  P         : POINTER ) : ST80;
  3462.  
  3463. [PARAMETERS]
  3464.  
  3465. P           Pointer to convert to a hex string
  3466.  
  3467. [RETURNS]
  3468.  
  3469. Hex string representation of pointer value
  3470.  
  3471. [DESCRIPTION]
  3472.  
  3473. Converts a Pointer into a hexadecimal string (both segment and offset)
  3474.  
  3475. [SEE-ALSO]
  3476.  
  3477. CharToHex
  3478. ByteToHex
  3479. IntToHex
  3480. WordToHex
  3481. LongToHex
  3482. HexToChar
  3483. HexToByte
  3484. HexToInt
  3485. HexToWord
  3486. HexToLong
  3487.  
  3488. [EXAMPLE]
  3489.  
  3490. VAR
  3491.   P : POINTER;
  3492.   S : STRING;
  3493.  
  3494. BEGIN
  3495.  
  3496.   P := Ptr($A000,0);
  3497.   S := PtrToHex( P );
  3498.  
  3499.   { S = 'A000:0000' }
  3500.  
  3501. END;
  3502.  
  3503. ──────────────────────────────────────────────────────────────────────────────
  3504.  
  3505.  
  3506. [FUNCTION]
  3507.  
  3508. Function  LongToHex(                 L         : LONGINT ) : ST80;
  3509.  
  3510. [PARAMETERS]
  3511.  
  3512. L           Signed Double Word (LONGINT) Value to convert to a hex string
  3513.  
  3514. [RETURNS]
  3515.  
  3516. Hex string representation of Longint value
  3517.  
  3518. [DESCRIPTION]
  3519.  
  3520. Converts a Signed Double Word (LONGINT) into a hexadecimal string
  3521.  
  3522. [SEE-ALSO]
  3523.  
  3524. CharToHex
  3525. ByteToHex
  3526. IntToHex
  3527. WordToHex
  3528. PtrToHex
  3529. HexToChar
  3530. HexToByte
  3531. HexToInt
  3532. HexToWord
  3533. HexToLong
  3534.  
  3535. [EXAMPLE]
  3536.  
  3537. VAR
  3538.   S : STRING;
  3539.  
  3540. BEGIN
  3541.  
  3542.   S := LongToHex( 123456789 );
  3543.  
  3544.   { S = '075BCD15' }
  3545.  
  3546. END;
  3547.  
  3548.  
  3549. ──────────────────────────────────────────────────────────────────────────────
  3550.  
  3551.  
  3552. [FUNCTION]
  3553.  
  3554. Function DecToHexStr(                S         : STRING   ) : STRING;
  3555.  
  3556. [PARAMETERS]
  3557.  
  3558. S           Decimal Value in String Format
  3559.  
  3560. [RETURNS]
  3561.  
  3562. Hexidecimal Value String
  3563.  
  3564. [DESCRIPTION]
  3565.  
  3566. Converts a Decimal Value String into a Hexidecimal Value String.
  3567. The Result is 8 Characters Long.  The Caller must strip the any
  3568. Leading Zeros to the desired size.
  3569.  
  3570. [SEE-ALSO]
  3571.  
  3572. CharToHex
  3573. ByteToHex
  3574. IntToHex
  3575. WordToHex
  3576. PtrToHex
  3577. HexToChar
  3578. HexToByte
  3579. HexToInt
  3580. HexToWord
  3581. HexToLong
  3582. HexToDecStr
  3583.  
  3584. [EXAMPLE]
  3585.  
  3586. VAR
  3587.   S : STRING;
  3588.  
  3589. BEGIN
  3590.  
  3591.   S := '1234';
  3592.   S := DecToHexStr( S );
  3593.  
  3594.   { S = '000004D2' - Caller Must Strip Leading Zeros if desired }
  3595.  
  3596. END;
  3597.  
  3598.  
  3599. ──────────────────────────────────────────────────────────────────────────────
  3600.  
  3601.  
  3602. [FUNCTION]
  3603.  
  3604. Function HexToDecStr(                S         : STRING   ) : STRING;
  3605.  
  3606. [PARAMETERS]
  3607.  
  3608. S           Hexadecimal Value in String Format
  3609.  
  3610. [RETURNS]
  3611.  
  3612. Decimal Value String
  3613.  
  3614. [DESCRIPTION]
  3615.  
  3616. Converts a Hexadecimal Value String into a Decimal Longint Value String.
  3617.  
  3618. [SEE-ALSO]
  3619.  
  3620. CharToHex
  3621. ByteToHex
  3622. IntToHex
  3623. WordToHex
  3624. PtrToHex
  3625. HexToChar
  3626. HexToByte
  3627. HexToInt
  3628. HexToWord
  3629. HexToLong
  3630. DecToHexStr
  3631.  
  3632. [EXAMPLE]
  3633.  
  3634. VAR
  3635.   S : STRING;
  3636.  
  3637. BEGIN
  3638.  
  3639.   S := '04D2';
  3640.   S := HexToDecStr( S );
  3641.  
  3642.   { S = '1234', Caller must Strip to Size Desired }
  3643.  
  3644. END;
  3645.  
  3646.  
  3647. ──────────────────────────────────────────────────────────────────────────────
  3648.  
  3649.  
  3650. [FUNCTION]
  3651.  
  3652. Function  HexToChar(                 S         : ST80    ) : SHORTINT;
  3653.  
  3654. [PARAMETERS]
  3655.  
  3656. S           String representation of signed byte hex value
  3657.  
  3658. [RETURNS]
  3659.  
  3660. Signed byte value represented by hex string
  3661.  
  3662. [DESCRIPTION]
  3663.  
  3664. Converts a hexadecimal string representation of a signed byte into
  3665. a signed byte value.  If Error then value is Zero.
  3666.  
  3667. [SEE-ALSO]
  3668.  
  3669. CharToHex
  3670. ByteToHex
  3671. IntToHex
  3672. WordToHex
  3673. PtrToHex
  3674. LongToHex
  3675. HexToByte
  3676. HexToInt
  3677. HexToWord
  3678. HexToLong
  3679.  
  3680. [EXAMPLE]
  3681.  
  3682. VAR
  3683.   I : SHORTINT;
  3684.  
  3685. BEGIN
  3686.  
  3687.   I := HexToChar( '80' );
  3688.  
  3689.   { I = -128 }
  3690.  
  3691. END;
  3692.  
  3693.  
  3694. ──────────────────────────────────────────────────────────────────────────────
  3695.  
  3696.  
  3697. [FUNCTION]
  3698.  
  3699. Function  HexToByte(                 S         : ST80    ) : BYTE;
  3700.  
  3701. [PARAMETERS]
  3702.  
  3703. S           String representation of byte hex value
  3704.  
  3705. [RETURNS]
  3706.  
  3707. Byte represented by hex string.
  3708.  
  3709. [DESCRIPTION]
  3710.  
  3711. Converts a hexadecimal string representation of a byte into a byte value.
  3712. If Error then value is Zero.
  3713.  
  3714. [SEE-ALSO]
  3715.  
  3716. CharToHex
  3717. ByteToHex
  3718. IntToHex
  3719. WordToHex
  3720. PtrToHex
  3721. LongToHex
  3722. HexToChar
  3723. HexToInt
  3724. HexToWord
  3725. HexToLong
  3726.  
  3727. [EXAMPLE]
  3728.  
  3729. VAR
  3730.   B : BYTE;
  3731.  
  3732. BEGIN
  3733.  
  3734.   B := HexToByte( '80' );
  3735.  
  3736.   { B = 128 }
  3737.  
  3738. END;
  3739.  
  3740.  
  3741. ──────────────────────────────────────────────────────────────────────────────
  3742.  
  3743.  
  3744. [FUNCTION]
  3745.  
  3746. Function  HexToInt(                  S         : ST80    ) : INTEGER;
  3747.  
  3748. [PARAMETERS]
  3749.  
  3750. S           String representation of integer hex value
  3751.  
  3752. [RETURNS]
  3753.  
  3754. Integer represented by hex string
  3755.  
  3756. [DESCRIPTION]
  3757.  
  3758. Converts a hexadecimal string representation of an integer (signed word)
  3759. into an integer value.  If Error then value is Zero.
  3760.  
  3761. [SEE-ALSO]
  3762.  
  3763. CharToHex
  3764. ByteToHex
  3765. IntToHex
  3766. WordToHex
  3767. PtrToHex
  3768. LongToHex
  3769. HexToChar
  3770. HexToByte
  3771. HexToWord
  3772. HexToLong
  3773.  
  3774. [EXAMPLE]
  3775.  
  3776. VAR
  3777.   I : INTEGER;
  3778.  
  3779. BEGIN
  3780.  
  3781.   I := HexToInt( '8300' );
  3782.  
  3783.   { I = -32000 }
  3784.  
  3785. END;
  3786.  
  3787.  
  3788. ──────────────────────────────────────────────────────────────────────────────
  3789.  
  3790.  
  3791. [FUNCTION]
  3792.  
  3793. Function  HexToWord(                 S         : ST80    ) : WORD;
  3794.  
  3795. [PARAMETERS]
  3796.  
  3797. S           String representation of a word hex value
  3798.  
  3799. [RETURNS]
  3800.  
  3801. Word represented by hex string
  3802.  
  3803. [DESCRIPTION]
  3804.  
  3805. Converts a hexadecimal string representation of a word into a word value.
  3806. If Error then value is Zero.
  3807.  
  3808. [SEE-ALSO]
  3809.  
  3810. CharToHex
  3811. ByteToHex
  3812. IntToHex
  3813. WordToHex
  3814. PtrToHex
  3815. LongToHex
  3816. HexToChar
  3817. HexToByte
  3818. HexToInt
  3819. HexToLong
  3820.  
  3821. [EXAMPLE]
  3822.  
  3823. VAR
  3824.   W : WORD;
  3825.  
  3826. BEGIN
  3827.  
  3828.   W := HexToWord( 'C350' );
  3829.  
  3830.   { W = 50000 }
  3831.  
  3832. END;
  3833.  
  3834.  
  3835. ──────────────────────────────────────────────────────────────────────────────
  3836.  
  3837.  
  3838. [FUNCTION]
  3839.  
  3840. Function  HexToLong(                 S         : ST80    ) : LONGINT;
  3841.  
  3842. [PARAMETERS]
  3843.  
  3844. S           String representation of longint hex value (double word)
  3845.  
  3846. [RETURNS]
  3847.  
  3848. Longint represented by hex string
  3849.  
  3850. [DESCRIPTION]
  3851.  
  3852. Converts a hexadecimal string representation of a longint (signed double
  3853. word) into a longint value.  If Error then value is Zero.
  3854.  
  3855. [SEE-ALSO]
  3856.  
  3857. CharToHex
  3858. ByteToHex
  3859. IntToHex
  3860. WordToHex
  3861. PtrToHex
  3862. LongToHex
  3863. HexToChar
  3864. HexToByte
  3865. HexToInt
  3866. HexToWord
  3867.  
  3868. [EXAMPLE]
  3869.  
  3870. VAR
  3871.   L : LONGINT;
  3872.  
  3873. BEGIN
  3874.  
  3875.   L := HexToLong( '075BCD15' );
  3876.  
  3877.   { L = 123456789 }
  3878.  
  3879. END;
  3880.  
  3881.  
  3882.  
  3883. ──────────────────────────────────────────────────────────────────────────────
  3884.  
  3885.  
  3886. [FUNCTION]
  3887.  
  3888. Function  ByteToBin(                 B         : BYTE    ) : ST80;
  3889.  
  3890. [PARAMETERS]
  3891.  
  3892. B           Byte value to convert to a binary string
  3893.  
  3894. [RETURNS]
  3895.  
  3896. Binary string representation of byte value
  3897.  
  3898. [DESCRIPTION]
  3899.  
  3900. Converts a byte value into a binary string
  3901.  
  3902. [SEE-ALSO]
  3903.  
  3904. IntToBin
  3905. WordToBin
  3906. LongToBin
  3907. BinToChar
  3908. BinToByte
  3909. BinToInt
  3910. BinToWord
  3911. BinToLong
  3912.  
  3913. [EXAMPLE]
  3914.  
  3915. VAR
  3916.   S : STRING;
  3917.  
  3918. BEGIN
  3919.  
  3920.   S := ByteToBin( 125 );
  3921.  
  3922.   { S = '01111101' }
  3923.  
  3924. END;
  3925.  
  3926.  
  3927. ──────────────────────────────────────────────────────────────────────────────
  3928.  
  3929.  
  3930. [FUNCTION]
  3931.  
  3932. Function  IntToBin(                  I         : INTEGER ) : ST80;
  3933.  
  3934. [PARAMETERS]
  3935.  
  3936. I           Integer (signed word) value to convert to a binary string
  3937.  
  3938. [RETURNS]
  3939.  
  3940. Binary string representation of integer value.
  3941.  
  3942. [DESCRIPTION]
  3943.  
  3944. Converts a integer (signed word) value into a binary string
  3945.  
  3946. [SEE-ALSO]
  3947.  
  3948. ByteToBin
  3949. WordToBin
  3950. LongToBin
  3951. BinToChar
  3952. BinToByte
  3953. BinToInt
  3954. BinToWord
  3955. BinToLong
  3956.  
  3957. [EXAMPLE]
  3958.  
  3959. VAR
  3960.   S : STRING;
  3961.  
  3962. BEGIN
  3963.  
  3964.   S := IntToBin( -32000 );
  3965.  
  3966.   { S = '1000001100000000' }
  3967.  
  3968. END;
  3969.  
  3970.  
  3971. ──────────────────────────────────────────────────────────────────────────────
  3972.  
  3973.  
  3974. [FUNCTION]
  3975.  
  3976. Function  WordToBin(                 W         : WORD    ) : ST80;
  3977.  
  3978. [PARAMETERS]
  3979.  
  3980. W           Word value to convert to a binary string
  3981.  
  3982. [RETURNS]
  3983.  
  3984. Binary string representation of word value
  3985.  
  3986. [DESCRIPTION]
  3987.  
  3988. Converts a word value into a binary string
  3989.  
  3990. [SEE-ALSO]
  3991.  
  3992. ByteToBin
  3993. IntToBin
  3994. LongToBin
  3995. BinToChar
  3996. BinToByte
  3997. BinToInt
  3998. BinToWord
  3999. BinToLong
  4000.  
  4001. [EXAMPLE]
  4002.  
  4003. VAR
  4004.   S : STRING;
  4005.  
  4006. BEGIN
  4007.  
  4008.   S := WordToBin( 50000 );
  4009.  
  4010.   { S = '1100001101010000' }
  4011.  
  4012. END;
  4013.  
  4014.  
  4015. ──────────────────────────────────────────────────────────────────────────────
  4016.  
  4017.  
  4018. [FUNCTION]
  4019.  
  4020. Function  LongToBin(                 L         : LONGINT ) : ST80;
  4021.  
  4022. [PARAMETERS]
  4023.  
  4024. L           Longint (signed double word) value to convert to binary string
  4025.  
  4026. [RETURNS]
  4027.  
  4028. Binary string representation of Longint
  4029.  
  4030. [DESCRIPTION]
  4031.  
  4032. Converts a longint (signed double word) value into a binary string
  4033.  
  4034. [SEE-ALSO]
  4035.  
  4036. ByteToBin
  4037. IntToBin
  4038. WordToBin
  4039. BinToChar
  4040. BinToByte
  4041. BinToInt
  4042. BinToWord
  4043. BinToLong
  4044.  
  4045. [EXAMPLE]
  4046.  
  4047. VAR
  4048.   S : STRING;
  4049.  
  4050. BEGIN
  4051.  
  4052.   S := LongToBin( 123456789 );
  4053.  
  4054.   { S = '00000111010110111100110100010101' }
  4055.  
  4056. END;
  4057.  
  4058.  
  4059. ──────────────────────────────────────────────────────────────────────────────
  4060.  
  4061.  
  4062. [FUNCTION]
  4063.  
  4064. Function  BinToChar(                 S         : ST80    ) : SHORTINT;
  4065.  
  4066. [PARAMETERS]
  4067.  
  4068. S           Binary string to convert to a signed byte value
  4069.  
  4070. [RETURNS]
  4071.  
  4072. Signed byte value of binary string
  4073.  
  4074. [DESCRIPTION]
  4075.  
  4076. Converts a binary string into a signed byte value.
  4077. If Error then value is Zero.
  4078.  
  4079. [SEE-ALSO]
  4080.  
  4081. ByteToBin
  4082. IntToBin
  4083. WordToBin
  4084. LongToBin
  4085. BinToByte
  4086. BinToInt
  4087. BinToWord
  4088. BinToLong
  4089.  
  4090. [EXAMPLE]
  4091.  
  4092. VAR
  4093.   I : SHORTINT;
  4094.  
  4095. BEGIN
  4096.  
  4097.   I := BinToChar( '10000000' );
  4098.   { I = -128 }
  4099.  
  4100. END;
  4101.  
  4102.  
  4103. ──────────────────────────────────────────────────────────────────────────────
  4104.  
  4105.  
  4106. [FUNCTION]
  4107.  
  4108. Function  BinToByte(                 S         : ST80    ) : BYTE;
  4109.  
  4110. [PARAMETERS]
  4111.  
  4112. S           Binary string to convert to a byte value
  4113.  
  4114. [RETURNS]
  4115.  
  4116. Byte value of binary string
  4117.  
  4118. [DESCRIPTION]
  4119.  
  4120. Converts a binary string into an unsigned byte value.
  4121. If Error then value is Zero.
  4122.  
  4123. [SEE-ALSO]
  4124.  
  4125. ByteToBin
  4126. IntToBin
  4127. WordToBin
  4128. LongToBin
  4129. BinToChar
  4130. BinToInt
  4131. BinToWord
  4132. BinToLong
  4133.  
  4134. [EXAMPLE]
  4135.  
  4136. VAR
  4137.   B : BYTE;
  4138.  
  4139. BEGIN
  4140.  
  4141.   B := BinToChar( '10000000' );
  4142.   { B = 128 }
  4143.  
  4144. END;
  4145.  
  4146.  
  4147. ──────────────────────────────────────────────────────────────────────────────
  4148.  
  4149.  
  4150. [FUNCTION]
  4151.  
  4152. Function  BinToInt(                  S         : ST80    ) : INTEGER;
  4153.  
  4154. [PARAMETERS]
  4155.  
  4156. S           Binary string to convert to an integer (signed word) value
  4157.  
  4158. [RETURNS]
  4159.  
  4160. Integer value of binary string
  4161.  
  4162. [DESCRIPTION]
  4163.  
  4164. Converts a binary string into an integer value.
  4165. If Error then value is Zero.
  4166.  
  4167. [SEE-ALSO]
  4168.  
  4169. ByteToBin
  4170. IntToBin
  4171. WordToBin
  4172. LongToBin
  4173. BinToChar
  4174. BinToByte
  4175. BinToWord
  4176. BinToLong
  4177.  
  4178. [EXAMPLE]
  4179.  
  4180. VAR
  4181.   I : INTEGER;
  4182.  
  4183. BEGIN
  4184.  
  4185.   I := BinToInt( '1000001100000000' );
  4186.  
  4187.   { I := -32000 }
  4188.  
  4189. END;
  4190.  
  4191.  
  4192. ──────────────────────────────────────────────────────────────────────────────
  4193.  
  4194.  
  4195. [FUNCTION]
  4196.  
  4197. Function  BinToWord(                 S         : ST80    ) : WORD;
  4198.  
  4199. [PARAMETERS]
  4200.  
  4201. S           Binary string to convert to a word value
  4202.  
  4203. [RETURNS]
  4204.  
  4205. Word value of binary string
  4206.  
  4207. [DESCRIPTION]
  4208.  
  4209. Converts a binary string into a word value.
  4210. If Error then value is Zero.
  4211.  
  4212. [SEE-ALSO]
  4213.  
  4214. ByteToBin
  4215. IntToBin
  4216. WordToBin
  4217. LongToBin
  4218. BinToChar
  4219. BinToByte
  4220. BinToInt
  4221. BinToLong
  4222.  
  4223. [EXAMPLE]
  4224.  
  4225. VAR
  4226.   W : WORD;
  4227.  
  4228. BEGIN
  4229.  
  4230.   W := BinToWord( '1100001101010000' );
  4231.  
  4232.   { W = 50000 }
  4233.  
  4234. END;
  4235.  
  4236.  
  4237. ──────────────────────────────────────────────────────────────────────────────
  4238.  
  4239.  
  4240. [FUNCTION]
  4241.  
  4242. Function  BinToLong(                 S         : ST80    ) : LONGINT;
  4243.  
  4244. [PARAMETERS]
  4245.  
  4246. S           Binary String to convert to a longint (signed double word) value
  4247.  
  4248. [RETURNS]
  4249.  
  4250. Longint value of binary string
  4251.  
  4252. [DESCRIPTION]
  4253.  
  4254. Converts a binary string into a longint value.
  4255. If Error then value is Zero.
  4256.  
  4257. [SEE-ALSO]
  4258.  
  4259. ByteToBin
  4260. IntToBin
  4261. WordToBin
  4262. LongToBin
  4263. BinToChar
  4264. BinToByte
  4265. BinToInt
  4266. BinToWord
  4267.  
  4268. [EXAMPLE]
  4269.  
  4270. VAR
  4271.   L : LONGINT;
  4272.  
  4273. BEGIN
  4274.  
  4275.   L := BinToLong( '00000111010110111100110100010101' );
  4276.  
  4277.   { L = 123456789 }
  4278.  
  4279. END;
  4280.  
  4281.  
  4282. ──────────────────────────────────────────────────────────────────────────────
  4283.  
  4284.  
  4285. [FUNCTION]
  4286.  
  4287. Function  DecToBCD(                  Decimal   : BYTE    ) : BYTE;
  4288.  
  4289. [PARAMETERS]
  4290.  
  4291. Decimal     Decimal Byte value (ranging from 0 to 99) to convert to a
  4292.             BCD byte value.
  4293.  
  4294. [RETURNS]
  4295.  
  4296. BCD value of Decimal byte value.
  4297.  
  4298. [DESCRIPTION]
  4299.  
  4300. Converts a decimal value ranging from 0 to 99 to Binary Coded Decimal
  4301. Format as a byte.
  4302.  
  4303. [SEE-ALSO]
  4304.  
  4305. BCDtoDec
  4306. ByteToBCD
  4307. BCDtoByte
  4308. WordToBCD
  4309. BCDtoWord
  4310.  
  4311. [EXAMPLE]
  4312.  
  4313. VAR
  4314.   B : BYTE;
  4315.  
  4316. BEGIN
  4317.  
  4318.   B := DecToBCD( 14 );
  4319.  
  4320.   { B = $14 }
  4321.  
  4322. END;
  4323.  
  4324.  
  4325. ──────────────────────────────────────────────────────────────────────────────
  4326.  
  4327.  
  4328. [FUNCTION]
  4329.  
  4330. Function  BCDtoDec(                  Bcd       : BYTE    ) : BYTE;
  4331.  
  4332. [PARAMETERS]
  4333.  
  4334. Bcd         BCD Byte value (ranging 00h - 99h) to convert to a decimal
  4335.             byte value.
  4336.  
  4337. [RETURNS]
  4338.  
  4339. Decimal byte value of BCD byte value.
  4340.  
  4341. [DESCRIPTION]
  4342.  
  4343. Converts a BCD byte value ranging fron 00h to 99h to a decimal byte value
  4344.  
  4345. [SEE-ALSO]
  4346.  
  4347. DecToBCD
  4348. ByteToBCD
  4349. BCDtoByte
  4350. WordToBCD
  4351. BCDtoWord
  4352.  
  4353. [EXAMPLE]
  4354.  
  4355. VAR
  4356.   B : BYTE;
  4357.  
  4358. BEGIN
  4359.  
  4360.   B := BCDtoDec( $14 );
  4361.  
  4362.   { B = 14 }
  4363.  
  4364. END;
  4365.  
  4366.  
  4367. ──────────────────────────────────────────────────────────────────────────────
  4368.  
  4369.  
  4370. [FUNCTION]
  4371.  
  4372. Function  ByteToBCD(                 Decimal   : BYTE    ) : WORD;
  4373.  
  4374. [PARAMETERS]
  4375.  
  4376. Decimal     Decimal byte value (ranging from 0 to 255) to convert to
  4377.             a BCD word value
  4378.  
  4379. [RETURNS]
  4380.  
  4381. BCD word value of decimal byte value.
  4382.  
  4383. [DESCRIPTION]
  4384.  
  4385. Converts a Decimal byte value ranging from 0 to 255 to Binary Coded
  4386. Decimal format as a word.
  4387.  
  4388. [SEE-ALSO]
  4389.  
  4390. DecToBCD
  4391. BCDtoDec
  4392. BCDtoByte
  4393. WordToBCD
  4394. BCDtoWord
  4395.  
  4396. [EXAMPLE]
  4397.  
  4398. VAR
  4399.   W : WORD;
  4400.  
  4401. BEGIN
  4402.  
  4403.   W := ByteToBCD( 255 );
  4404.  
  4405.   { W = $0255 }
  4406.  
  4407. END;
  4408.  
  4409.  
  4410. ──────────────────────────────────────────────────────────────────────────────
  4411.  
  4412.  
  4413. [FUNCTION]
  4414.  
  4415. Function  BCDtoByte(                 Bcd       : WORD    ) : BYTE;
  4416.  
  4417. [PARAMETERS]
  4418.  
  4419. Bcd         BCD Word value (ranging from 0000h to 0255h) to convert to
  4420.             a decimal byte value.
  4421.  
  4422. [RETURNS]
  4423.  
  4424. Decimal byte value of BCD word value.
  4425.  
  4426. [DESCRIPTION]
  4427.  
  4428. Converts a BCD word value ranging from 0000h to 0255h to a decimal byte
  4429. value.
  4430.  
  4431. [SEE-ALSO]
  4432.  
  4433. DecToBCD
  4434. BCDtoDec
  4435. ByteToBCD
  4436. WordToBCD
  4437. BCDtoWord
  4438.  
  4439. [EXAMPLE]
  4440.  
  4441. VAR
  4442.   B : BYTE;
  4443.  
  4444. BEGIN
  4445.  
  4446.   B := BCDtoByte( $0255 );
  4447.  
  4448.   { B = 255 }
  4449.  
  4450. END;
  4451.  
  4452.  
  4453. ──────────────────────────────────────────────────────────────────────────────
  4454.  
  4455.  
  4456. [FUNCTION]
  4457.  
  4458. Function  WordToBCD(                 Decimal   : WORD    ) : LONGINT;
  4459.  
  4460. [PARAMETERS]
  4461.  
  4462. Decimal     Decimal word value (ranging from 0 to 65535) to convert to
  4463.             a BCD longint value
  4464.  
  4465. [RETURNS]
  4466.  
  4467. BCD longint value of decimal word value
  4468.  
  4469. [DESCRIPTION]
  4470.  
  4471. Converts a Decimal word value ranging from 0 to 65535 to Binary Coded
  4472. Decimal format as a longint.
  4473.  
  4474. [SEE-ALSO]
  4475.  
  4476. DecToBCD
  4477. BCDtoDec
  4478. ByteToBCD
  4479. BCDtoByte
  4480. BCDtoWord
  4481.  
  4482. [EXAMPLE]
  4483.  
  4484. VAR
  4485.   L : LONGINT;
  4486.  
  4487. BEGIN
  4488.  
  4489.   L := WordToBCD( 54321 );
  4490.  
  4491.   { L = $00054321 }
  4492.  
  4493. END;
  4494.  
  4495.  
  4496. ──────────────────────────────────────────────────────────────────────────────
  4497.  
  4498.  
  4499. [FUNCTION]
  4500.  
  4501. Function  BCDtoWord(                 Bcd       : LONGINT ) : WORD;
  4502.  
  4503. [PARAMETERS]
  4504.  
  4505. Bcd         BCD longint value (ranging from 00000000h to 00065535h) to
  4506.             convert to a decimal word value
  4507.  
  4508. [RETURNS]
  4509.  
  4510. Decimal word value of BCD longint value
  4511.  
  4512. [DESCRIPTION]
  4513.  
  4514. Converts a BCD longint value ranging fron 00000000h to 00065536h to a
  4515. decimal word value.
  4516.  
  4517. [SEE-ALSO]
  4518.  
  4519. DecToBCD
  4520. BCDtoDec
  4521. ByteToBCD
  4522. BCDtoByte
  4523. WordToBCD
  4524.  
  4525. [EXAMPLE]
  4526.  
  4527. VAR
  4528.   W : WORD;
  4529.  
  4530. BEGIN
  4531.  
  4532.   W := BCDtoWord( $00054321 );
  4533.  
  4534.   { W = 54321 }
  4535.  
  4536. END;
  4537.  
  4538.  
  4539. ──────────────────────────────────────────────────────────────────────────────
  4540.  
  4541.  
  4542. [FUNCTION]
  4543.  
  4544. [PARAMETERS]
  4545.  
  4546. [RETURNS]
  4547.  
  4548. [DESCRIPTION]
  4549.  
  4550. [SEE-ALSO]
  4551.  
  4552. [EXAMPLE]
  4553.  
  4554.  
  4555. GetStrNumType( '$1234' ) = 2
  4556.  
  4557.  
  4558. ──────────────────────────────────────────────────────────────────────────────
  4559.  
  4560.  
  4561. [FUNCTION]
  4562.  
  4563. [PARAMETERS]
  4564.  
  4565. [RETURNS]
  4566.  
  4567. [DESCRIPTION]
  4568.  
  4569. [SEE-ALSO]
  4570.  
  4571. [EXAMPLE]
  4572.  
  4573.  
  4574. ──────────────────────────────────────────────────────────────────────────────
  4575.  
  4576.  
  4577. [FUNCTION]
  4578.  
  4579. Function  StrToIntEx(                S         : STRING  ) : INTEGER;
  4580.  
  4581. [PARAMETERS]
  4582.  
  4583. S           Source String representing Integer Value
  4584.  
  4585. [RETURNS]
  4586.  
  4587. Integer Value
  4588.  
  4589. [DESCRIPTION]
  4590.  
  4591. ****** THIS FUNCTION NOT IMPLEMENTED! ******
  4592.  
  4593. [SEE-ALSO]
  4594.  
  4595. [EXAMPLE]
  4596.  
  4597.  
  4598. ──────────────────────────────────────────────────────────────────────────────
  4599.  
  4600.  
  4601. [FUNCTION]
  4602.  
  4603. [PARAMETERS]
  4604.  
  4605. [RETURNS]
  4606.  
  4607. [DESCRIPTION]
  4608.  
  4609. [SEE-ALSO]
  4610.  
  4611. [EXAMPLE]
  4612.  
  4613.  
  4614. ──────────────────────────────────────────────────────────────────────────────
  4615.  
  4616.  
  4617. [FUNCTION]
  4618.  
  4619. Function  FastCompare(           Var Buf1;
  4620.                                  Var Buf2;
  4621.                                      Count     : WORD    ) : WORD;
  4622.  
  4623. [PARAMETERS]
  4624.  
  4625. Buffer1     VAR Address of First Buffer (Generic Type)
  4626. Buffer2     VAR Address of Second Buffer (Generic Type)
  4627. Count       Number of bytes in each buffer
  4628.  
  4629. [RETURNS]
  4630.  
  4631. Whether or not the provided Buffers were the same (0=Same, $FFFF=Not)
  4632.  
  4633. [DESCRIPTION]
  4634.  
  4635. This function compares two data buffers and returns a non-zero value
  4636. if the buffers data does not compare.  It doesn't indicate which byte
  4637. index the miscompare exists, just that it did.  If the data in both
  4638. buffers are alike the result is Zero.  This Operation is Optimized in
  4639. Assembly for the fastest possible Comparison.
  4640.  
  4641. [SEE-ALSO]
  4642.  
  4643. Compare
  4644. CompareSmaller
  4645. CompareBufByte
  4646.  
  4647. [EXAMPLE]
  4648.  
  4649. TYPE
  4650.   TBuff = ARRAY[1..10] of BYTE;
  4651.  
  4652. VAR
  4653.   B1,B2 : TBuff;
  4654.   W     : WORD;
  4655.  
  4656. BEGIN
  4657.  
  4658.   FillChar( B1, SizeOf( B1 ), 4 );
  4659.   FillChar( B2, SizeOf( B2 ), 4 );
  4660.  
  4661.   B2[7] := 49;  { Force MisCompare }
  4662.  
  4663.   W := FastCompare( B1, B2, SizeOf( TBuff ) );
  4664.  
  4665.   { W = $FFFF  - MisCompared! }
  4666.  
  4667. END;
  4668.  
  4669.  
  4670. ──────────────────────────────────────────────────────────────────────────────
  4671.  
  4672.  
  4673. [FUNCTION]
  4674.  
  4675. Function  Compare(               Var Buf1;
  4676.                                  Var Buf2;
  4677.                                      Count     : WORD    ) : WORD;
  4678.  
  4679. [PARAMETERS]
  4680.  
  4681. Buf1        VAR Address of First Buffer (Generic Type)
  4682. Buf2        VAR Address of Second Buffer (Generic Type)
  4683. Count       Number of bytes in each buffer (Max = $FFFE bytes)
  4684.  
  4685. [RETURNS]
  4686.  
  4687. Index of First Miscompared Byte in Buffers, 0 if Buffers the Same
  4688.  
  4689. [DESCRIPTION]
  4690.  
  4691. This function compares two data buffers and returns a non-zero value
  4692. if the buffer's data does not compare.  This number will be the index
  4693. of the first byte miscompared between the two bufffers or Zero if the
  4694. buffers were alike.  This Operation is Optimized in Assembly for the
  4695. fastests possible Comparison.
  4696.  
  4697. [SEE-ALSO]
  4698.  
  4699. FastCompare
  4700. CompareSmaller
  4701. CompareBufByte
  4702.  
  4703. [EXAMPLE]
  4704.  
  4705. TYPE
  4706.   TBuff = ARRAY[1..10] of BYTE;
  4707.  
  4708. VAR
  4709.   B1,B2 : TBuff;
  4710.   W     : WORD;
  4711.  
  4712. BEGIN
  4713.  
  4714.   FillChar( B1, SizeOf( B1 ), 4 );
  4715.   FillChar( B2, SizeOf( B2 ), 4 );
  4716.  
  4717.   B2[7] := 49;  { Force MisCompare }
  4718.  
  4719.   W := Compare( B1, B2, SizeOf( TBuff ) );
  4720.  
  4721.   { W = 7  - MisCompare Index! }
  4722.  
  4723. END;
  4724.  
  4725.  
  4726. ──────────────────────────────────────────────────────────────────────────────
  4727.  
  4728.  
  4729. [FUNCTION]
  4730.  
  4731. Function  CompareSmaller(        Var Buf1;
  4732.                                  Var Buf2;
  4733.                                      Count     : WORD    ) : SHORTINT;
  4734.  
  4735. [PARAMETERS]
  4736.  
  4737. Buf1        VAR Address of First Buffer (Generic Type)
  4738. Buf2        VAR Address of Second Buffer (Generic Type)
  4739. Count       Number of bytes in each buffer (Max = $FFFE bytes)
  4740.  
  4741. [RETURNS]
  4742.  
  4743. Which Buffer Data contains the Smaller Value or if they Match
  4744.   -1 if first is smaller than the second buffer
  4745.    0 if they are the same
  4746.    1 if first is bigger than the second buffer
  4747.  
  4748. [DESCRIPTION]
  4749.  
  4750. This function tests two buffers to see which Buffer Data contains a smaller
  4751. value.  At the first Miscompare, the one with the lesser Value is indicated
  4752. with a non-zero value (-1 if the 1st Buffer byte is smaller than the 2nd,
  4753. 1 if the 1st Buffer byte is greater than the 2nd, or 0 [Zero] if they are
  4754. both the same).
  4755.  
  4756. [SEE-ALSO]
  4757.  
  4758. FastCompare
  4759. Compare
  4760. CompareBufByte
  4761.  
  4762. [EXAMPLE]
  4763.  
  4764. TYPE
  4765.   TBuff = ARRAY[1..10] of BYTE;
  4766.  
  4767. VAR
  4768.   B1,B2 : TBuff;
  4769.   I     : INTEGER;
  4770.  
  4771. BEGIN
  4772.  
  4773.   FillChar( B1, SizeOf( B1 ), 4 );
  4774.   FillChar( B2, SizeOf( B2 ), 4 );
  4775.  
  4776.   B2[7] := 49;  { Force MisCompare }
  4777.  
  4778.   I := CompareSmaller( B1, B2, SizeOf( TBuff ) );
  4779.  
  4780.   { I = -1  - MisCompare, 1st Buffer Smaller! }
  4781.  
  4782. END;
  4783.  
  4784.  
  4785. ──────────────────────────────────────────────────────────────────────────────
  4786.  
  4787.  
  4788. [FUNCTION]
  4789.  
  4790. Function  CompareBufByte(        Var Buff;
  4791.                                      Count     : WORD;
  4792.                                      B         : BYTE    ) : WORD;
  4793.  
  4794. [PARAMETERS]
  4795.  
  4796. Buff        VAR Address of Buffer (Generic Type)
  4797. Count       Number of bytes in each buffer (Max = $FFFE byte)
  4798. B           Comparison byte
  4799.  
  4800. [RETURNS]
  4801.  
  4802. Index of First Miscompared byte in Buffer, 0 if Buffer all data matches
  4803. Compare Byte
  4804.  
  4805. [DESCRIPTION]
  4806.  
  4807. Compares a buffer with a byte value to determine whether or not all bytes
  4808. in that buffer are the same as the comparison byte.  Returns Zero if all
  4809. buffer data bytes match the compare byte, otherwise returns the index
  4810. into the buffer of the miscompare.
  4811.  
  4812. [SEE-ALSO]
  4813.  
  4814. FastCompare
  4815. Compare
  4816. CompareSmaller
  4817.  
  4818. [EXAMPLE]
  4819.  
  4820. TYPE
  4821.   TBuffer = ARRAY[1..512] of BYTE;
  4822.  
  4823. VAR
  4824.   B : TBuffer;
  4825.   C : BYTE;
  4826.   W : WORD;
  4827.  
  4828. BEGIN
  4829.  
  4830.   { COMPARE MATCH }
  4831.  
  4832.   FillChar( B, 512, #30 );
  4833.   C := #30;
  4834.   W := CompareBufByte( B, 512, C );
  4835.  
  4836.   { W will now equal 0 (Comparison Match) }
  4837.  
  4838.   { COMPARE MISMATCH }
  4839.  
  4840.   B[274] := $FF;  { Just to make sure Doesn't Compare }
  4841.   W := CompareBufByte( B, 512, C );
  4842.  
  4843.   { W will now Equal 274 (Index of Mismatch) }
  4844.  
  4845. END.
  4846.  
  4847. TYPE
  4848.   TBuff = ARRAY[1..10] of BYTE;
  4849.  
  4850. VAR
  4851.   Buf : TBuff;
  4852.   B   : BYTE;
  4853.   W   : WORD;
  4854.  
  4855. BEGIN
  4856.  
  4857.   FillChar( Bur, SizeOf( TBuff ), 4 );
  4858.   Buf[7] := 49;  { Force MisCompare! }
  4859.  
  4860.   W := CompareSmaller( Buf, SizeOf( TBuff ), $04 );
  4861.  
  4862.   { W = 7  - MisCompare Index! }
  4863.  
  4864. END;
  4865.  
  4866.  
  4867. ──────────────────────────────────────────────────────────────────────────────
  4868.  
  4869.  
  4870. [FUNCTION]
  4871.  
  4872. Function  CompareBufWord(        Var Buff;
  4873.                                      Count     : WORD;
  4874.                                      W         : WORD    ) : WORD;
  4875.  
  4876. [PARAMETERS]
  4877.  
  4878. Buff        VAR Address of Buffer (Generic Type)
  4879. Count       Number of Words in each buffer (Max of $FFFE bytes)
  4880. W           2-Byte Comparison Value
  4881.  
  4882. [RETURNS]
  4883.  
  4884. Word Index of First Miscompared Word in Buffer, 0 if Buffer all data
  4885. matches the 2-Byte Compare Value (a Word)
  4886.  
  4887. [DESCRIPTION]
  4888.  
  4889. Compares a buffer with a 2-Byte value (a WORD) to determine whether or
  4890. not all Words in that buffer are the same as the comparison byte.
  4891. Returns Zero if all buffer data words match the compare word, otherwise
  4892. returns the Word Index into the buffer of the miscompare.
  4893.  
  4894. [SEE-ALSO]
  4895.  
  4896. FastCompare
  4897. Compare
  4898. CompareSmaller
  4899.  
  4900. [EXAMPLE]
  4901.  
  4902. TYPE
  4903.   TBuffer = ARRAY[1..256] of BYTE;
  4904.  
  4905. VAR
  4906.   B : TBuffer;
  4907.   C : BYTE;
  4908.   W : WORD;
  4909.  
  4910. BEGIN
  4911.  
  4912.   { COMPARE MATCH }
  4913.  
  4914.   FillChar( B, SizeOf( TBuffer ), #30 );
  4915.   C := #30;
  4916.   W := CompareBufByte( B, 256, C );
  4917.  
  4918.   { W will now equal 0 (Comparison Match) }
  4919.  
  4920.   { COMPARE MISMATCH }
  4921.  
  4922.   B[137] := $FF;  { Just to make sure Doesn't Compare }
  4923.   W := CompareBufByte( B, 256, C );
  4924.  
  4925.   { W will now Equal 137 (Index of Mismatch) }
  4926.  
  4927. END.
  4928.  
  4929.  
  4930. ──────────────────────────────────────────────────────────────────────────────
  4931.  
  4932.  
  4933. [FUNCTION]
  4934.  
  4935. Function  LookupByte(                 InByte   : BYTE;
  4936.                                       Count    : WORD;
  4937.                                   Var LTable;
  4938.                                   Var OutByte  : BYTE              ) : BOOLEAN;
  4939.  
  4940. [PARAMETERS]
  4941.  
  4942. InByte      Source Byte to look up in Table
  4943. Count       Number of entries in the lookup table
  4944. LTable      Address of the lookup table
  4945. OutByte     Byte indentified by source byte in table
  4946.  
  4947. [RETURNS]
  4948.  
  4949. TRUE if the source byte was found in the table, FALSE if one was not.
  4950.  
  4951. [DESCRIPTION]
  4952.  
  4953. This function allow a quick lookup of a 2-byte record (the first byte
  4954. being the lookup key and the 2nd byte being the data to find).  The
  4955. actual record is set up as in the example below.  It is an array of
  4956. translation records (see example).
  4957.  
  4958. You pass in a prepared lookup table and ask it to find the data
  4959. associated with a specific "key".  This can be useful for such actions
  4960. as translation tables for error codes, etc.
  4961.  
  4962. [SEE-ALSO]
  4963.  
  4964. LookupWord
  4965.  
  4966. [EXAMPLE]
  4967.  
  4968. Type
  4969.   TTableRec = RECORD
  4970.     Key  : BYTE;
  4971.     Data : BYTE;
  4972.   END;
  4973.  
  4974.   TTable = Array[1..6] of TTableRec;
  4975.  
  4976. VAR
  4977.   T : TTable;
  4978.   B : BYTE;
  4979.  
  4980. BEGIN
  4981.  
  4982.   T[1].Key :=  0;   T[1].Data := 14;
  4983.   T[2].Key :=  3;   T[2].Data := 12;
  4984.   T[3].Key :=  7;   T[3].Data := 54;
  4985.   T[4].Key := 12;   T[4].Data :=  2;
  4986.   T[5].Key := 14;   T[5].Data :=  7;
  4987.   T[6].Key := 15;   T[6].Data :=  9;
  4988.  
  4989.   If LookupByte( 12, 6, @T, B ) Then
  4990.     WriteLn( 'Item Found in Table.  Data=',B )
  4991.   Else
  4992.     WriteLn( 'Item NOT Found in Table.' );
  4993.  
  4994.   {------------------------------------------------}
  4995.   { Output would be "Item Found in Table.  Data=2" }
  4996.   {------------------------------------------------}
  4997.  
  4998. END.
  4999.  
  5000.  
  5001. ──────────────────────────────────────────────────────────────────────────────
  5002.  
  5003.  
  5004. [FUNCTION]
  5005.  
  5006. Function  LookupWord(                 InWord   : WORD;
  5007.                                       Count    : WORD;
  5008.                                   Var LTable;
  5009.                                   Var OutWord  : WORD              ) : BOOLEAN;
  5010.  
  5011. [PARAMETERS]
  5012.  
  5013. InWord      Source word to look up in table
  5014. Count       Number of entries in the lookup table
  5015. LTable      Address of the lookup table
  5016. OutWord     Word indentified by source byte in table
  5017.  
  5018. [RETURNS]
  5019.  
  5020. TRUE if the source word was found in the table, FALSE if one was not.
  5021.  
  5022. [DESCRIPTION]
  5023.  
  5024. This function allow a quick lookup of a 4-byte record (the first word
  5025. being the lookup key and the second word being the data to find).  The
  5026. actual record is set up as in the example below.  It is an array of
  5027. translation records (see example).
  5028.  
  5029. You pass in a prepared lookup table and ask it to find the data
  5030. associated with a specific "key".  This can be useful for such actions
  5031. as translation tables for error codes, etc.
  5032.  
  5033. [SEE-ALSO]
  5034.  
  5035. LookupWord
  5036.  
  5037. [EXAMPLE]
  5038.  
  5039. TYPE
  5040.   TTableRec = RECORD
  5041.     Key  : WORD;
  5042.     Data : WORD;
  5043.   END;
  5044.  
  5045.   TTable = Array[1..6] of TTableRec;
  5046.  
  5047. VAR
  5048.   T : TTable;
  5049.   W : WORD;
  5050.  
  5051. BEGIN
  5052.  
  5053.   T[1].Key :=  0;   T[1].Data := 14;
  5054.   T[2].Key :=  3;   T[2].Data := 12;
  5055.   T[3].Key :=  7;   T[3].Data := 54;
  5056.   T[4].Key := 12;   T[4].Data :=  2;
  5057.   T[5].Key := 14;   T[5].Data :=  7;
  5058.   T[6].Key := 15;   T[6].Data :=  9;
  5059.  
  5060.   If LookupByte( 12, 6, @T, B ) Then
  5061.     WriteLn( 'Item Found in Table.  Data=',B )
  5062.   Else
  5063.     WriteLn( 'Item NOT Found in Table.' );
  5064.  
  5065.   {------------------------------------------------}
  5066.   { Output would be "Item Found in Table.  Data=2" }
  5067.   {------------------------------------------------}
  5068.  
  5069. END.
  5070.  
  5071.  
  5072. ──────────────────────────────────────────────────────────────────────────────
  5073.  
  5074.  
  5075. [FUNCTION]
  5076.  
  5077. Procedure SwapBuffers(           Var Buf1;
  5078.                                  Var Buf2;
  5079.                                      Count     : WORD    );
  5080.  
  5081. [PARAMETERS]
  5082.  
  5083. Buf1        VAR Address of First buffer of data
  5084. Buf2        VAR Address of Second buffer of data
  5085. Count       Number of bytes to swap
  5086.  
  5087. [RETURNS]
  5088.  
  5089. (None)
  5090.  
  5091. [DESCRIPTION]
  5092.  
  5093. Swaps a given number of bytes between two types/untyped buffers.
  5094.  
  5095. [SEE-ALSO]
  5096.  
  5097. [EXAMPLE]
  5098.  
  5099. TYPE
  5100.   TBuff = ARRAY[1..10] of BYTE;
  5101.  
  5102. VAR
  5103.   B1,B2 : TBuff;
  5104.  
  5105. BEGIN
  5106.  
  5107.   FillChar( B1, SizeOf( B1 ), 1 );
  5108.   FillChar( B2, SizeOf( B2 ), 2 );
  5109.  
  5110.   SwapBuffers( B1,B2, SizeOf( TBuff ) );
  5111.  
  5112.   { B1 now filled with 2's and B2 filled with 1's }
  5113.  
  5114. END;
  5115.  
  5116.  
  5117. ──────────────────────────────────────────────────────────────────────────────
  5118.  
  5119.  
  5120. [FUNCTION]
  5121.  
  5122. Procedure SwapWords(             Var A,
  5123.                                      B         : WORD    );
  5124.  
  5125. [PARAMETERS]
  5126.  
  5127. A           VAR First word to swap
  5128. B           VAR Second word to swap
  5129.  
  5130. [RETURNS]
  5131.  
  5132. (None)
  5133.  
  5134. [DESCRIPTION]
  5135.  
  5136. Executes a bufferless two-word swap
  5137.  
  5138. [SEE-ALSO]
  5139.  
  5140. SwapInts
  5141. SwapBytes
  5142.  
  5143. [EXAMPLE]
  5144.  
  5145. VAR
  5146.   W1,W2 : WORD;
  5147.  
  5148. BEGIN
  5149.  
  5150.   W1 := 5;
  5151.   W2 := 3;
  5152.  
  5153.   SwapWords( W1, W2 );
  5154.  
  5155.   { W1 = 3, W2 = 5 }
  5156.  
  5157. END;
  5158.  
  5159.  
  5160. ──────────────────────────────────────────────────────────────────────────────
  5161.  
  5162.  
  5163. [FUNCTION]
  5164.  
  5165. Procedure SwapInts(              Var A,
  5166.                                      B         : INTEGER );
  5167.  
  5168. [PARAMETERS]
  5169.  
  5170. A           VAR First integer to swap
  5171. B           VAR Second integer to swap
  5172.  
  5173. [RETURNS]
  5174.  
  5175. (None)
  5176.  
  5177. [DESCRIPTION]
  5178.  
  5179. Executes a bufferless two-integer swap
  5180.  
  5181. [SEE-ALSO]
  5182.  
  5183. SwapWords
  5184. SwapBytes
  5185.  
  5186. [EXAMPLE]
  5187.  
  5188. VAR
  5189.   I1,I2 : INTEGER;
  5190.  
  5191. BEGIN
  5192.  
  5193.   I1 :=  5;
  5194.   I2 := -3;
  5195.  
  5196.   SwapInts( I1, I2 );
  5197.  
  5198.   { I1 = -3; I2 = 5 }
  5199.  
  5200. END;
  5201.  
  5202.  
  5203. ──────────────────────────────────────────────────────────────────────────────
  5204.  
  5205.  
  5206. [FUNCTION]
  5207.  
  5208. Procedure SwapBytes(             Var A,
  5209.                                      B         : BYTE    );
  5210.  
  5211. [PARAMETERS]
  5212.  
  5213. A           VAR First byte to swap
  5214. B           VAR Second byte to swap
  5215.  
  5216. [RETURNS]
  5217.  
  5218. (None)
  5219.  
  5220. [DESCRIPTION]
  5221.  
  5222. Executes a Bufferless 2-Byte swap
  5223.  
  5224. [SEE-ALSO]
  5225.  
  5226. SwapWords
  5227. SwapInts
  5228.  
  5229. [EXAMPLE]
  5230.  
  5231. VAR
  5232.   B1,B2 : BYTE;
  5233.  
  5234. BEGIN
  5235.  
  5236.   B1 := 5;
  5237.   B2 := 3;
  5238.  
  5239.   SwapBytes( B1, B2 );
  5240.  
  5241.   { B1 = 3, B2 = 5 }
  5242.  
  5243. END;
  5244.  
  5245.  
  5246. ──────────────────────────────────────────────────────────────────────────────
  5247.  
  5248.  
  5249. [FUNCTION]
  5250.  
  5251. Function  GreaterInt(                A,
  5252.                                      B         : INTEGER ) : INTEGER;
  5253.  
  5254. [PARAMETERS]
  5255.  
  5256. A           First integer to compare
  5257. B           Second integer to compare
  5258.  
  5259. [RETURNS]
  5260.  
  5261. Greater of the two provided integer
  5262.  
  5263. [DESCRIPTION]
  5264.  
  5265. Compares two integer and returns the greater.
  5266.  
  5267. [SEE-ALSO]
  5268.  
  5269. GreaterWord
  5270. GreaterLong
  5271. LesserInt
  5272. LesserWord
  5273. LesserLong
  5274.  
  5275. [EXAMPLE]
  5276.  
  5277. VAR
  5278.   I1,I2,I3 : INTEGER;
  5279.  
  5280. BEGIN
  5281.  
  5282.   I1 :=  5;
  5283.   I2 := -3;
  5284.  
  5285.   I3 := GreaterInt( I1, I2 );
  5286.  
  5287.   { I3 = 5 }
  5288.  
  5289. END;
  5290.  
  5291.  
  5292. ──────────────────────────────────────────────────────────────────────────────
  5293.  
  5294.  
  5295. [FUNCTION]
  5296.  
  5297. Function  GreaterWord(               A,
  5298.                                      B         : WORD    ) : WORD;
  5299.  
  5300. [PARAMETERS]
  5301.  
  5302. A           First word to compare
  5303. B           Second word to compare
  5304.  
  5305. [RETURNS]
  5306.  
  5307. Greater of the two provided words
  5308.  
  5309. [DESCRIPTION]
  5310.  
  5311. Compares two words and returns the greater.
  5312.  
  5313. [SEE-ALSO]
  5314.  
  5315. GreaterInt
  5316. GreaterLong
  5317. LesserInt
  5318. LesserWord
  5319. LesserLong
  5320.  
  5321. [EXAMPLE]
  5322.  
  5323. VAR
  5324.   W1,W2,W3 : INTEGER;
  5325.  
  5326. BEGIN
  5327.  
  5328.   W1 := 5;
  5329.   W2 := 3;
  5330.  
  5331.   W3 := GreaterWord( W1, W2 );
  5332.  
  5333.   { W3 = 5 }
  5334.  
  5335. END;
  5336.  
  5337.  
  5338. ──────────────────────────────────────────────────────────────────────────────
  5339.  
  5340.  
  5341. [FUNCTION]
  5342.  
  5343. Function  GreaterLong(               A,
  5344.                                      B         : LONGINT ) : LONGINT;
  5345.  
  5346. [PARAMETERS]
  5347.  
  5348. A           First longint (signed double word) to compare
  5349. B           Second longint to compare
  5350.  
  5351. [RETURNS]
  5352.  
  5353. Greater of the two provided longints
  5354.  
  5355. [DESCRIPTION]
  5356.  
  5357. Compares two longints (signed double words) and returns the greater
  5358.  
  5359. [SEE-ALSO]
  5360.  
  5361. GreaterInt
  5362. GreaterWord
  5363. LesserInt
  5364. LesserWord
  5365. LesserLong
  5366.  
  5367. [EXAMPLE]
  5368.  
  5369. VAR
  5370.   L1,L2,L3 : INTEGER;
  5371.  
  5372. BEGIN
  5373.  
  5374.   L1 := 5;
  5375.   L2 := 3;
  5376.  
  5377.   L3 := GreaterLong( L1, L2 );
  5378.  
  5379.   { L3 = 5 }
  5380.  
  5381. END;
  5382.  
  5383.  
  5384. ──────────────────────────────────────────────────────────────────────────────
  5385.  
  5386.  
  5387. [FUNCTION]
  5388.  
  5389. Function  LesserInt(                 A,
  5390.                                      B         : INTEGER ) : INTEGER;
  5391.  
  5392. [PARAMETERS]
  5393.  
  5394. A           First integer to compare
  5395. B           Second integer to compare
  5396.  
  5397. [RETURNS]
  5398.  
  5399. Lesser of the two integers
  5400.  
  5401. [DESCRIPTION]
  5402.  
  5403. Compares two integers and returns the lesser
  5404.  
  5405. [SEE-ALSO]
  5406.  
  5407. GreaterInt
  5408. GreaterWord
  5409. GreaterLong
  5410. LesserWord
  5411. LesserLong
  5412.  
  5413. [EXAMPLE]
  5414.  
  5415. VAR
  5416.   I1,I2,I3 : INTEGER;
  5417.  
  5418. BEGIN
  5419.  
  5420.   I1 :=  5;
  5421.   I2 := -3;
  5422.  
  5423.   I3 := LesserLong( I1, I2 );
  5424.  
  5425.   { I3 = -3 }
  5426.  
  5427. END;
  5428.  
  5429.  
  5430. ──────────────────────────────────────────────────────────────────────────────
  5431.  
  5432.  
  5433. [FUNCTION]
  5434.  
  5435. Function  LesserWord(                A,
  5436.                                      B         : WORD    ) : WORD;
  5437.  
  5438. [PARAMETERS]
  5439.  
  5440. A           First word to compare
  5441. B           Second word to compare
  5442.  
  5443. [RETURNS]
  5444.  
  5445. Lesser of the two words
  5446.  
  5447. [DESCRIPTION]
  5448.  
  5449. Compares two words and returns the lesser
  5450.  
  5451. [SEE-ALSO]
  5452.  
  5453. GreaterInt
  5454. GreaterWord
  5455. GreaterLong
  5456. LesserInt
  5457. LesserLong
  5458.  
  5459. [EXAMPLE]
  5460.  
  5461. VAR
  5462.   W1,W2,W3 : WORD;
  5463.  
  5464. BEGIN
  5465.  
  5466.   W1 := 5;
  5467.   W2 := 3;
  5468.  
  5469.   W3 := LesserWord( W1, W2 );
  5470.  
  5471.   { W3 = 3 }
  5472.  
  5473. END;
  5474.  
  5475.  
  5476. ──────────────────────────────────────────────────────────────────────────────
  5477.  
  5478.  
  5479. [FUNCTION]
  5480.  
  5481. Function  LesserLong(                A,
  5482.                                      B         : LONGINT ) : LONGINT;
  5483.  
  5484. [PARAMETERS]
  5485.  
  5486. A           First longint (double word) to compare
  5487. B           Second longint to compare
  5488.  
  5489. [RETURNS]
  5490.  
  5491. Lesser of the two longints
  5492.  
  5493. [DESCRIPTION]
  5494.  
  5495. Compares two longints (signed double words) and returns the lesser
  5496.  
  5497. [SEE-ALSO]
  5498.  
  5499. GreaterInt
  5500. GreaterWord
  5501. GreaterLong
  5502. LesserInt
  5503. LesserWord
  5504.  
  5505. [EXAMPLE]
  5506.  
  5507. VAR
  5508.   L1,L2,L3 : INTEGER;
  5509.  
  5510. BEGIN
  5511.  
  5512.   L1 := 5;
  5513.   L2 := 3;
  5514.  
  5515.   L3 := LesserLong( L1, L2 );
  5516.  
  5517.   { L3 = 3 }
  5518.  
  5519. END;
  5520.  
  5521.  
  5522. ──────────────────────────────────────────────────────────────────────────────
  5523.  
  5524.  
  5525. [FUNCTION]
  5526.  
  5527. Procedure FillWord(              Var Buf;
  5528.                                      Count     : WORD;
  5529.                                      Value     : WORD    );
  5530. [PARAMETERS]
  5531.  
  5532. Buf         VAR Address of untyped Buffer to fill
  5533. Count       Number of Words to Fill
  5534. Value       Word Value to fill Buffer with
  5535.  
  5536. [RETURNS]
  5537.  
  5538. Function : None
  5539. (Var     : [Buf] Buffer fill with Value)
  5540.  
  5541. [DESCRIPTION]
  5542.  
  5543. Takes an Untyped Buffer and fills it with a given Word Value "Value"
  5544. up to the number of Words given in "Count".  This is the same thing
  5545. as PASCAL's FillChar except it allows you to fill with 2-Byte Patterns
  5546. instead.
  5547.  
  5548. WARNING: Make sure Count Represents Buffer Size in Terms of 2-Byte
  5549. Words rather than simply the number of bytes of the Buffer.  Otherwise
  5550. this may result in a buffer overrun, potentially overwritting other
  5551. data in memory.
  5552.  
  5553. [SEE-ALSO]
  5554.  
  5555. FillLong
  5556.  
  5557. [EXAMPLE]
  5558.  
  5559. TYPE
  5560.   TBuff = ARRAY[1..12] of BYTE;
  5561.  
  5562. VAR
  5563.   B : TBuff;
  5564.  
  5565. BEGIN
  5566.  
  5567.   FillWord( B, SizeOf( B ) DIV 2, $1234 );
  5568.  
  5569.   { Entire Buffer (B) Filled with 2-Byte Value $1234 }
  5570.  
  5571. END;
  5572.  
  5573.  
  5574. ──────────────────────────────────────────────────────────────────────────────
  5575.  
  5576.  
  5577. Procedure FillLong(              Var Buf;
  5578.                                      Count     : WORD;
  5579.                                      Value     : LONGINT );
  5580. [PARAMETERS]
  5581.  
  5582. Buf         VAR Address of untyped Buffer to fill
  5583. Count       Number of Words to Fill
  5584. Value       Longint Value to fill Buffer with
  5585.  
  5586. [RETURNS]
  5587.  
  5588. Function : None
  5589. (Var     : [Buf] Buffer fill with Value)
  5590.  
  5591. [DESCRIPTION]
  5592.  
  5593. Takes an Untyped Buffer and fills it with a given Longint Value "Value"
  5594. up to the number of Longints given in "Count".  This is the same thing
  5595. as PASCAL's FillChar except it allows you to fill with 4-Byte Patterns
  5596. instead.
  5597.  
  5598. WARNING: Make sure Count Represents Buffer Size in Terms of 4-Byte
  5599. Words rather than simply the number of bytes of the Buffer.  Otherwise
  5600. this may result in a buffer overrun, potentially overwritting other
  5601. data in memory.
  5602.  
  5603. [SEE-ALSO]
  5604.  
  5605. FillWord
  5606.  
  5607. [EXAMPLE]
  5608.  
  5609. TYPE
  5610.   TBuff = ARRAY[1..12] of BYTE;
  5611.  
  5612. VAR
  5613.   B : TBuff;
  5614.  
  5615. BEGIN
  5616.  
  5617.   FillWord( B, SizeOf( B ) DIV 4, $12345678 );
  5618.  
  5619.   { Entire Buffer (B) Filled with 4-Byte Value $12345678 }
  5620.  
  5621. END;
  5622.  
  5623.  
  5624. ──────────────────────────────────────────────────────────────────────────────
  5625.  
  5626.  
  5627. [FUNCTION]
  5628.  
  5629. Procedure RebootMachine(             WarmBoot : BOOLEAN );
  5630.  
  5631. [PARAMETERS]
  5632.  
  5633. WarmBoot   TRUE to warmboot machine,
  5634.            FALSE to coldboot (do post and memory checks)
  5635.  
  5636.  
  5637. [RETURNS]
  5638.  
  5639. (None)
  5640.  
  5641. [DESCRIPTION]
  5642.  
  5643. Reboots the system.
  5644.  
  5645.  
  5646.   ++++++++++++++++++++++++++++++++++++++++++++++++
  5647.   +                                              +
  5648.   + NOTE:                                        +
  5649.   +                                              +
  5650.   + On AT and compatible machines, the keyboard  +
  5651.   + controller is wired to the CPUs reboot line. +
  5652.   + Here we tell the keyboard controller to      +
  5653.   + wiggle the reboot line.  This is the same    +
  5654.   + thing that the code at $FFFF:0 does.         +
  5655.   + We talk to the keyboard controller directly  +
  5656.   + because you would otherwise need to make     +
  5657.   + DPMI calls when in protected/windows mode.   +
  5658.   +                                              +
  5659.   ++++++++++++++++++++++++++++++++++++++++++++++++
  5660.  
  5661. [SEE-ALSO]
  5662.  
  5663. [EXAMPLE]
  5664.  
  5665.  
  5666. BEGIN
  5667.  
  5668.   WriteLn( 'Ready to Reboot your System.' );
  5669.   WriteLn( 'Press "W" to WarmBoot, otherwise will Coldboot' );
  5670.  
  5671.   RebootMachine( UpCase( ReadKey ) = 'W' );
  5672.  
  5673. END;
  5674.  
  5675.  
  5676. ──────────────────────────────────────────────────────────────────────────────
  5677.  
  5678.  
  5679. [FUNCTION]
  5680.  
  5681. Procedure SetKeyRate(                Delay     : BYTE;
  5682.                                      Rate      : BYTE    );
  5683.  
  5684. [PARAMETERS]
  5685.  
  5686. Delay       Delay value to set keyboard repeat to
  5687. Rate        Rate at which keys are read after delay period
  5688.  
  5689. [RETURNS]
  5690.  
  5691. (None)
  5692.  
  5693. [DESCRIPTION]
  5694.  
  5695. Sets the Keyboard typematic Rate and Delay times.
  5696.  
  5697. Delay       Delay value to set keyboard repeat to (this is a table)
  5698.                 00h =  250ms  02h =  750ms
  5699.                 01h =  500ms  03h = 1000ms
  5700.  
  5701. Rate        Rate at which keys are read after delay period (this is a table)
  5702.                Value Table is as such:
  5703.                 00h = 30.0ms  08h = 15.0ms  10h =  7.5ms  18h =  3.7ms
  5704.                 01h = 26.7ms  09h = 13.3ms  11h =  6.7ms  19h =  3.3ms
  5705.                 02h = 24.0ms  0Ah = 12.0ms  12h =  6.0ms  1Ah =  3.0ms
  5706.                 03h = 21.8ms  0Bh = 10.9ms  13h =  5.5ms  1Bh =  2.7ms
  5707.                 04h = 20.0ms  0Ch = 10.0ms  14h =  5.0ms  1Ch =  2.5ms
  5708.                 05h = 18.5ms  0Dh =  9.2ms  15h =  4.6ms  1Dh =  2.3ms
  5709.                 06h = 17.1ms  0Eh =  8.6ms  16h =  4.3ms  1Eh =  2.1ms
  5710.                 07h = 16.0ms  0Fh =  8.0ms  17h =  4.0ms  1Fh =  2.0ms
  5711. [SEE-ALSO]
  5712.  
  5713. SetKeyFast
  5714.  
  5715. [EXAMPLE]
  5716.  
  5717. VAR
  5718.   ch : CHAR;
  5719.  
  5720. BEGIN
  5721.  
  5722.   WriteLn( 'Setting Fastest Key Rate & Least Delay' );
  5723.   SetkeyRate( $00, $00 );
  5724.  
  5725.   WriteLn( 'Test by typing any key, <ENTER> to go to next test.' );
  5726.   REPEAT
  5727.     ch := ReadKey;
  5728.     Write( ch );
  5729.   UNTIL ch = #13;
  5730.  
  5731.   WriteLn( 'Setting Slowest Key Rate & Greatest Delay' );
  5732.   SetKeyRate( $03, $1F );
  5733.  
  5734.   WriteLn( 'Test by typing any key, <ESC> to quit test.' );
  5735.   REPEAT
  5736.     ch := ReadKey;
  5737.     Write( ch );
  5738.   UNTIL ch = #27;
  5739.  
  5740.   WriteLn( 'Resetting keyboard to Default Rate & Delay' );
  5741.   SetKeyRate( $01, $04 );
  5742.  
  5743. END;
  5744.  
  5745.  
  5746. ──────────────────────────────────────────────────────────────────────────────
  5747.  
  5748.  
  5749. [FUNCTION]
  5750.  
  5751. Procedure SetKeyFast;
  5752.  
  5753. [PARAMETERS]
  5754.  
  5755. (None)
  5756.  
  5757. [RETURNS]
  5758.  
  5759. (None)
  5760.  
  5761. [DESCRIPTION]
  5762.  
  5763. Sets the keyboard delay and rate to its maximum value
  5764.  
  5765. [SEE-ALSO]
  5766.  
  5767. SetKeyRate
  5768.  
  5769. [EXAMPLE]
  5770.  
  5771. VAR
  5772.   ch : CHAR;
  5773.  
  5774. BEGIN
  5775.  
  5776.   WriteLn( 'Test Current Keyboard Setting' );
  5777.   WriteLn( 'Test by typing any key, <ENTER> to for Fastest Speed.' );
  5778.   REPEAT
  5779.     ch := ReadKey;
  5780.     Write( ch );
  5781.   UNTIL ch = #13;
  5782.  
  5783.   WriteLn( 'Setting Fastest Key Rate & Least Delay' );
  5784.   SetkeyFast;
  5785.   WriteLn( 'Test by typing any key, <ESC> to go to quit.' );
  5786.   REPEAT
  5787.     ch := ReadKey;
  5788.     Write( ch );
  5789.   UNTIL ch = #27;
  5790.  
  5791. END;
  5792.  
  5793.  
  5794. ──────────────────────────────────────────────────────────────────────────────
  5795.  
  5796.  
  5797. [FUNCTION]
  5798.  
  5799. Procedure PurgeKbdBuf;
  5800.  
  5801. [PARAMETERS]
  5802.  
  5803. (None)
  5804.  
  5805. [RETURNS]
  5806.  
  5807. (None)
  5808.  
  5809. [DESCRIPTION]
  5810.  
  5811. Flushes the Keyboard type-ahead buffer.  Keyboard buffer is now empty
  5812. and like nothing has been pressed.
  5813.  
  5814. [SEE-ALSO]
  5815.  
  5816. [EXAMPLE]
  5817.  
  5818. VAR
  5819.   ch : CHAR;
  5820.  
  5821. BEGIN
  5822.  
  5823.   WriteLn( 'Hold down a Key until Keyboard Buffer is Full (Beeps)' );
  5824.   WriteLn( 'and Keep Holding that Key.' );
  5825.  
  5826.   While NOT KeyPressed Do;
  5827.  
  5828.   Delay(2000);
  5829.  
  5830.   WriteLn( 'Purging Key Buffer.  And Accepting Keystokes... <ESC>=Quit' );
  5831.   PurgeKbdBuf;
  5832.  
  5833.   REPEAT
  5834.     ch := ReadKey;
  5835.     Write( ch );
  5836.   UNTIL ch = #27;
  5837.  
  5838. END;
  5839.  
  5840.  
  5841. ──────────────────────────────────────────────────────────────────────────────
  5842.  
  5843.  
  5844. [FUNCTION]
  5845.  
  5846. Procedure KeyboardOff;
  5847.  
  5848. [PARAMETERS]
  5849.  
  5850. (None)
  5851.  
  5852. [RETURNS]
  5853.  
  5854. (None)
  5855.  
  5856. [DESCRIPTION]
  5857.  
  5858. Turns off keyboard access to the system
  5859.  
  5860. [SEE-ALSO]
  5861.  
  5862. KeyboardOn
  5863.  
  5864. [EXAMPLE]
  5865.  
  5866. VAR
  5867.   ch : CHAR;
  5868.  
  5869. BEGIN
  5870.  
  5871.   WriteLn( 'Type any Key to demonstrate Keyboard Active.' );
  5872.   WriteLn( 'Press <ENTER> when Ready for Test.' );
  5873.   REPEAT
  5874.     ch := ReadKey;
  5875.     Write( ch );
  5876.   UNTIL ch = #13;
  5877.  
  5878.   KeyboardOff;
  5879.   WriteLn( 'Keyboard is Now INACTIVE for 5 seconds.');
  5880.   WriteLn( 'Try to Press a Key.' );
  5881.   Delay( 5000 );
  5882.  
  5883.   KeyboardOn;
  5884.  
  5885.   WriteLn( 'Keyboard is ACTIVE again. Press any key.  <ESC>=Quit' )
  5886.   REPEAT
  5887.     ch := Readkey;
  5888.     Write( ch );
  5889.   UNTIL ch = #27;
  5890.  
  5891.   WriteLn( 'End of Test' );
  5892.  
  5893. END;
  5894.  
  5895.  
  5896. ──────────────────────────────────────────────────────────────────────────────
  5897.  
  5898.  
  5899. [FUNCTION]
  5900.  
  5901. Procedure KeyboardOn;
  5902.  
  5903. [PARAMETERS]
  5904.  
  5905. (None)
  5906.  
  5907. [RETURNS]
  5908.  
  5909. (None)
  5910.  
  5911. [DESCRIPTION]
  5912.  
  5913. Turms on keyboard access to the system
  5914.  
  5915. [SEE-ALSO]
  5916.  
  5917. KeyboardOff
  5918.  
  5919. [EXAMPLE]
  5920.  
  5921. VAR
  5922.   ch : CHAR;
  5923.  
  5924. BEGIN
  5925.  
  5926.   WriteLn( 'Type any Key to demonstrate Keyboard Active.' );
  5927.   WriteLn( 'Press <ENTER> when Ready for Test.' );
  5928.   REPEAT
  5929.     ch := ReadKey;
  5930.     Write( ch );
  5931.   UNTIL ch = #13;
  5932.  
  5933.   KeyboardOff;
  5934.   WriteLn( 'Keyboard is Now INACTIVE for 5 seconds.');
  5935.   WriteLn( 'Try to Press a Key.' );
  5936.   Delay( 5000 );
  5937.  
  5938.   KeyboardOn;
  5939.  
  5940.   WriteLn( 'Keyboard is ACTIVE again. Press any key.  <ESC>=Quit' )
  5941.   REPEAT
  5942.     ch := Readkey;
  5943.     Write( ch );
  5944.   UNTIL ch = #27;
  5945.  
  5946.   WriteLn( 'End of Test' );
  5947.  
  5948. END;
  5949.  
  5950.  
  5951. ──────────────────────────────────────────────────────────────────────────────
  5952.  
  5953.  
  5954. [FUNCTION]
  5955.  
  5956. Procedure CRC16Char(           Var Ch          : CHAR;
  5957.                                Var Result      : WORD );
  5958.  
  5959. [PARAMETERS]
  5960.  
  5961. Ch          VAR Address of Source Byte to CRC
  5962. Result      VAR Returned 16-Bit CRC Checksum on Source Byte
  5963.  
  5964. [RETURNS]
  5965.  
  5966. Function : None
  5967. (Var     : [Result] Returned 16-Bit CRC Checksum on Source Byte)
  5968.  
  5969. [DESCRIPTION]
  5970.  
  5971. [SEE-ALSO]
  5972.  
  5973. CRC16String
  5974. CRC16Buffer
  5975. CRC32Char
  5976. CRC32String
  5977. CRC32Buffer
  5978.  
  5979. [EXAMPLE]
  5980.  
  5981. VAR
  5982.   Ch    : CHAR;
  5983.   CRC16 : WORD;
  5984.  
  5985. BEGIN
  5986.  
  5987.   Ch := 'A';
  5988.  
  5989.   CRC16Char( Ch, CRC16 );
  5990.  
  5991.   { CRC16 = $0041 }
  5992.  
  5993. END;
  5994.  
  5995.  
  5996. ──────────────────────────────────────────────────────────────────────────────
  5997.  
  5998.  
  5999. [FUNCTION]
  6000.  
  6001. Procedure CRC16Buffer(         Var Buf;
  6002.                                    Count       : WORD;
  6003.                                Var Result      : WORD );
  6004.  
  6005. [PARAMETERS]
  6006.  
  6007. Buf         VAR Address of untyped Data Buffer to CRC
  6008. Count       Number of bytes in Data Buffer
  6009. Result      VAR 16-bit CRC totals on Data Buffer
  6010.  
  6011. [RETURNS]
  6012.  
  6013. Function : None
  6014. (Var     : [Result] 16-bit CRC on the Buffer)
  6015.  
  6016. [DESCRIPTION]
  6017.  
  6018. [SEE-ALSO]
  6019.  
  6020. CRC16Char
  6021. CRC16String
  6022. CRC32Char
  6023. CRC32String
  6024. CRC32Buffer
  6025.  
  6026. [EXAMPLE]
  6027.  
  6028. TYPE
  6029.   TBuff = ARRAY[1..10] of BYTE;
  6030.  
  6031. VAR
  6032.   B     : TBuff;
  6033.   CRC16 : WORD;
  6034.  
  6035. BEGIN
  6036.  
  6037.   FillChar( B, SizeOf( B ), $04 );
  6038.   CRC16 := 0;
  6039.  
  6040.   CRC16Buffer( B, SizeOf( B ), CRC16 );
  6041.  
  6042.   { CRC16 = $43D3 }
  6043.  
  6044. END;
  6045.  
  6046.  
  6047. ──────────────────────────────────────────────────────────────────────────────
  6048.  
  6049.  
  6050. [FUNCTION]
  6051.  
  6052. Procedure CRC32Char(           Var Ch          : CHAR;
  6053.                                Var Result      : LONGINT );
  6054.  
  6055. [PARAMETERS]
  6056.  
  6057. Ch          VAR Address of Source Byte to CRC
  6058. Result      VAR Returned 32-Bit CRC Checksum on Source Byte
  6059.  
  6060. [RETURNS]
  6061.  
  6062. Function : None
  6063. (Var     : [Result] 32-Bit CRC Checksum on Source Byte)
  6064.  
  6065. [DESCRIPTION]
  6066.  
  6067. [SEE-ALSO]
  6068.  
  6069. CRC16Char
  6070. CRC16String
  6071. CRC16Buffer
  6072. CRC32String
  6073. CRC32Buffer
  6074.  
  6075. [EXAMPLE]
  6076.  
  6077. VAR
  6078.   Ch    : CHAR;
  6079.   CRC32 : LONGINT;
  6080.  
  6081. BEGIN
  6082.  
  6083.   Ch := 'A';
  6084.  
  6085.   CRC32Char( Ch, CRC32 );
  6086.  
  6087.   { CRC32 = $01DB7106 }
  6088.  
  6089. END;
  6090.  
  6091.  
  6092. ──────────────────────────────────────────────────────────────────────────────
  6093.  
  6094.  
  6095. [FUNCTION]
  6096.  
  6097. Procedure CRC32Buffer(         Var Buf;
  6098.                                    Count       : WORD;
  6099.                                Var Result      : LONGINT );
  6100.  
  6101. [PARAMETERS]
  6102.  
  6103. [RETURNS]
  6104.  
  6105. [DESCRIPTION]
  6106.  
  6107. [SEE-ALSO]
  6108.  
  6109. CRC16Char
  6110. CRC16String
  6111. CRC16Buffer
  6112. CRC32Char
  6113. CRC32String
  6114.  
  6115. [EXAMPLE]
  6116.  
  6117. TYPE
  6118.   TBuff = ARRAY[1..10] of BYTE;
  6119.  
  6120. VAR
  6121.   B     : TBuff;
  6122.   CRC32 : LONGINT;
  6123.  
  6124. BEGIN
  6125.  
  6126.   FillChar( B, SizeOf( B ), $04 );
  6127.   CRC32 := 0;
  6128.  
  6129.   CRC32Buffer( B, SizeOf( B ), CRC32 );
  6130.  
  6131.   { CRC32 = $1716C742 }
  6132.  
  6133. END;
  6134.  
  6135. ──────────────────────────────────────────────────────────────────────────────
  6136.  
  6137.  
  6138. [FUNCTION]
  6139.  
  6140. Procedure Sort(               Var Buf;
  6141.                                   Index         : LONGINT;
  6142.                                   Count         : LONGINT;
  6143.                                   SortProc      : PSortProc;
  6144.                                   Params        : STRING        );
  6145.  
  6146. [PARAMETERS]
  6147.  
  6148. Buf         Untyped pointer to the base of the data element array.
  6149. Index       Element within array to begin sorting.
  6150. Count       Number of elements to sort in the table.
  6151. SortProc    Pointer to a comparison function.
  6152. Params      Parameter string with specific sorting information.
  6153.  
  6154. [RETURNS]
  6155.  
  6156. Buf         Sorted buffer
  6157.  
  6158. [DESCRIPTION]
  6159.  
  6160. Sorts a table of data elements using the Heapsort algorithm.  A user-supplied
  6161. comparison function is allowed for maximum flexability - but not required for
  6162. ShortInt, Byte, Integer, Word, LongInt, String, PString, PChar, and Real
  6163. types, which are all auto-formatted.
  6164.  
  6165. For "user-supplied" types, SortProc should be a function which Sort uses for
  6166. element comparisons.  Sort will pass two pointers that address elements in
  6167. the table being sorted.  The function should follow the TSortProc template,
  6168. where a -1 should be returned if the first parameter is less that the second,
  6169. 0 if the two parameters are equal, or +1 if the first parameter is greater
  6170. than the second.
  6171.  
  6172. The parameter string is a string containing a list of specific sorting
  6173. instructions to use.  The commands within the Params string must be comma
  6174. delimited with no spaces.
  6175.  
  6176. Parameter substrings are as follows:
  6177.  
  6178.   ElementType=$    Where $ is the type of element within the table.
  6179.                    Default is word type.
  6180.  
  6181.                    Allowed ElementTypes, preset ElementSize, and
  6182.                    kind of element for each include:
  6183.  
  6184.                    SHORTINT - 1    Ordinals
  6185.                    BYTE     - 1    Ordinals
  6186.                    INTEGER  - 2    Ordinals
  6187.                    WORD     - 2    Ordinals
  6188.                    LONGINT  - 4    Ordinals
  6189.                    STRING   - 256  Fixed-length (see below)
  6190.                    PSTRING  - 4    Pointers for Variant-length
  6191.                    PCHAR    - 4    Pointers for Variant-length
  6192.                    REAL     - 6    Floating-points
  6193.  
  6194.                    If the actual ElementSize for a String type is less
  6195.                    than 256 (ie. STRING[80]), use ElementSize afterwards to
  6196.                    reset to the lesser size.
  6197.  
  6198.                    If you are using an external compare function, then the
  6199.                    ElementType parameter should not be used.
  6200.  
  6201.   'ElementSize=#'  Where # is the size of each element within the table.
  6202.                    Default is 2, the size of a word.  Note that only User
  6203.                    types are not precasted in size, and must have this
  6204.                    parameter included.
  6205.  
  6206. [SEE-ALSO]
  6207.  
  6208. (None)
  6209.  
  6210. [EXAMPLE]
  6211.  
  6212. Var
  6213.  
  6214.   Table : Array[1..5] of STRING;
  6215.  
  6216. BEGIN
  6217.  
  6218.   Table[1] := 'ALPHA';
  6219.   Table[2] := 'CHARLIE';
  6220.   Table[3] := 'ECHO';
  6221.   Table[4] := 'DELTA';
  6222.   Table[5] := 'BRAVO';
  6223.  
  6224.   Sort( Table, 1, 5, NIL, 'ElementType=STRING' );
  6225.  
  6226. END;
  6227.  
  6228.  
  6229. ──────────────────────────────────────────────────────────────────────────────
  6230.  
  6231.  
  6232. [FUNCTION]
  6233.  
  6234. Function  SoundexPack(               S         : STRING  ) : WORD;
  6235.  
  6236. [PARAMETERS]
  6237.  
  6238. S           Text string (one text word) to Soundex Encode and pack
  6239.  
  6240. [RETURNS]
  6241.  
  6242. Packed (as WORD) Soundex Code for string
  6243.  
  6244. [DESCRIPTION]
  6245.  
  6246. Soundex Encodes a text string and packs it as word value.
  6247. A Soundex Code is an AlphaNumeric Code derived from the pronounciation
  6248. of a text word.  It's standard format is the first letter of the
  6249. original word along with a numbering system designed to encompass
  6250. sounds of similar pronounciation.  The result is that the Soundex Code
  6251. for a word is the same as a Soundex for a word which sounds the same.
  6252. (ie. "There", "Their", and "They're" would all have the same Soundex
  6253. Code).  This resulting code is further compressed from 4 bytes downto
  6254. the space of a single binary word (2 bytes).  Uses SoundexUnPack to
  6255. revert to it's standard Soundex Format.  This Packed Code may be used
  6256. just as you would the standard Soundex Code in all operations and uses.
  6257. In fact, it is recommended to be used in this format for saving of
  6258. record storage space as well as simplicity of comparison tests.
  6259.  
  6260. [SEE-ALSO]
  6261.  
  6262. SoundexUnPack
  6263. SoundexStr
  6264.  
  6265. [EXAMPLE]
  6266.  
  6267. VAR
  6268.   W1,W2 : WORD;
  6269.  
  6270. BEGIN
  6271.  
  6272.   W1 := SoundexPack( 'Jonson' );
  6273.   W2 := SoundexPack( 'Johnsonn' );
  6274.  
  6275.   { Both W1 and W2 contain the value 10765 }
  6276.  
  6277. END;
  6278.  
  6279.  
  6280. ──────────────────────────────────────────────────────────────────────────────
  6281.  
  6282.  
  6283. [FUNCTION]
  6284.  
  6285. Function  SoundexUnPack(             W         : WORD    ) : STRING;
  6286.  
  6287. [PARAMETERS]
  6288.  
  6289. W           Word representing Packed Soundex Code to be unpacked
  6290.  
  6291. [RETURNS]
  6292.  
  6293. Standard Unpacked Soundex Code from Packed Code Value
  6294.  
  6295. [DESCRIPTION]
  6296.  
  6297. Unpacks a soundex code from packed code value.
  6298. A Soundex Code is an AlphaNumeric Code derived from the pronounciation
  6299. of a text word.  It's standard format is the first letter of the
  6300. original word along with a numbering system designed to encompass
  6301. sounds of similar pronounciation.  (See SoundexPack for example)  This
  6302. takes the packed 2 byte compressed Soundex Code and uncompresses it
  6303. it's standard Soundex Format as a 4 byte string Code.  It is recommended
  6304. that for operational uses, the compressed for be used for both the
  6305. savings of record storage space as well as simplicity of comparison tests.
  6306.  
  6307. [SEE-ALSO]
  6308.  
  6309. SoundexPack
  6310. SoundexStr
  6311.  
  6312. [EXAMPLE]
  6313.  
  6314. VAR
  6315.   W : WORD;
  6316.   S : STRING;
  6317.  
  6318. BEGIN
  6319.  
  6320.   W := SoundexPack( 'Jonson' );
  6321.   S := SoundexUnPack( W );
  6322.  
  6323.   { W = 10765, S = 'J525' }
  6324.  
  6325. END;
  6326.  
  6327.  
  6328. ──────────────────────────────────────────────────────────────────────────────
  6329.  
  6330.  
  6331. [FUNCTION]
  6332.  
  6333. Function  SoundexStr(                S         : STRING  ) : STRING;
  6334.  
  6335. [PARAMETERS]
  6336.  
  6337. [RETURNS]
  6338.  
  6339. [DESCRIPTION]
  6340.  
  6341. For the rare instances when one would like to display the actual Soundex
  6342. Symbolic Code, this function will output that Symbolic Code as a string.
  6343.  
  6344. Use of this is more for show than actually utilizing the data, as it is
  6345. always faster and much more efficient to use a Packed Soundex Code value
  6346. for all comparison operations than to compare by Strings.
  6347.  
  6348. [SEE-ALSO]
  6349.  
  6350. SoundexPack
  6351. SoundexUnPack
  6352.  
  6353. [EXAMPLE]
  6354.  
  6355. VAR
  6356.   S : STRING;
  6357.  
  6358. BEGIN
  6359.  
  6360.   S := SoundexStr( 'Jonson' );
  6361.  
  6362.   { S = 'J525' }
  6363.  
  6364. END;
  6365.  
  6366.  
  6367. ──────────────────────────────────────────────────────────────────────────────
  6368.  
  6369.  
  6370. [FUNCTION]
  6371.  
  6372. Function  PtrToLin(                  Ptr       : POINTER ) : LONGINT;
  6373.  
  6374. [PARAMETERS]
  6375.  
  6376. Ptr         Pointer Address to Convert to Linear Address
  6377.  
  6378. [RETURNS]
  6379.  
  6380. Linear Address associated with Pointer Address
  6381.  
  6382. [DESCRIPTION]
  6383.  
  6384. Converts a Segmented Address Pointer into a Linear Memory Address.
  6385.  
  6386. This is most useful for Windows or DPMI Pointer routines.
  6387. This could also be used to manipulate Pointer Math.
  6388.  
  6389. [SEE-ALSO]
  6390.  
  6391. LinToPtr
  6392.  
  6393. [EXAMPLE]
  6394.  
  6395. VAR
  6396.   P : POINTER;
  6397.   L : LONGINT;
  6398.  
  6399. BEGIN
  6400.  
  6401.   P := Ptr( $A000, $0 );
  6402.   L := PtrToLin( P );
  6403.  
  6404.   { L = $000A0000 }
  6405.  
  6406. END;
  6407.  
  6408.  
  6409. ──────────────────────────────────────────────────────────────────────────────
  6410.  
  6411.  
  6412. [FUNCTION]
  6413.  
  6414. Function  LinToPtr(                  Lin       : LONGINT ) : POINTER;
  6415.  
  6416. [PARAMETERS]
  6417.  
  6418. Lin         Linear Memory Address
  6419.  
  6420. [RETURNS]
  6421.  
  6422. Pointer associated with same Linear Memory Address
  6423.  
  6424. [DESCRIPTION]
  6425.  
  6426. Converts a Linear Memory Address Longint into a Segmented Memory Addr
  6427. Pointer.
  6428.  
  6429. [SEE-ALSO]
  6430.  
  6431. PtrToLin
  6432.  
  6433. [EXAMPLE]
  6434.  
  6435. VAR
  6436.   P : POINTER;
  6437.   L : LONGINT;
  6438.  
  6439. BEGIN
  6440.  
  6441.   L := $000A0000;
  6442.   P := LinToPtr( L );
  6443.  
  6444.   { P = $A000:0000 }
  6445.  
  6446. END;
  6447.  
  6448.  
  6449. ──────────────────────────────────────────────────────────────────────────────
  6450.  
  6451.  
  6452. [FUNCTION]
  6453.  
  6454. Function  PtrAdd(                    OrigPtr   : POINTER;
  6455.                                      AddOfs    : LONGINT ) : POINTER;
  6456.  
  6457. [PARAMETERS]
  6458.  
  6459. OrigPtr     Source Pointer to work with
  6460. AddOfs      Pointer Offset to Add
  6461.  
  6462. [RETURNS]
  6463.  
  6464. New Pointer from the above pointer math
  6465.  
  6466. [DESCRIPTION]
  6467.  
  6468. This function will take the provided Source Pointer and Add to it the
  6469. Offset Address "AddOfs" to come up with another Pointer Address.  This
  6470. is math at the Pointer Level and comes in very useful with routines
  6471. emulating C Style Pointer operations.
  6472.  
  6473. [SEE-ALSO]
  6474.  
  6475. PtrSub
  6476.  
  6477. [EXAMPLE]
  6478.  
  6479. VAR
  6480.   T,P : POINTER;
  6481.   Len : INTEGER;
  6482.  
  6483. BEGIN
  6484.  
  6485.   T   := NewString( 300, 'This is a Test' + #0 );
  6486.   { T is now a "C"-Type String }
  6487.  
  6488.   P   := T;
  6489.   Len := 0;
  6490.  
  6491.   While ( P <> #0) Do
  6492.   BEGIN
  6493.     Inc( Len );
  6494.     P := PtrAdd( P, 1 );
  6495.   END;
  6496.  
  6497.   { Len now equals the length of the AsciiZ string }
  6498.  
  6499. END;
  6500.  
  6501.  
  6502. ──────────────────────────────────────────────────────────────────────────────
  6503.  
  6504.  
  6505. [FUNCTION]
  6506.  
  6507. Function  PtrSub(                    OrigPtr   : POINTER;
  6508.                                      SubOfs    : LONGINT ) : POINTER;
  6509.  
  6510. [PARAMETERS]
  6511.  
  6512. OrigPtr     Source Pointer to work with
  6513. SubOfs      Pointer Offset to Subtract
  6514.  
  6515. [RETURNS]
  6516.  
  6517. New Pointer from the above pointer math
  6518.  
  6519. [DESCRIPTION]
  6520.  
  6521. This function will take the provided Source Pointer and Subtract from
  6522. it's address the Offset "SubOfs" to produce another pointer.  This is
  6523. basically math at the Pointer Level and can be very useful when used
  6524. much like C Pointer routines
  6525.  
  6526. Suggest that this may be more useful moving Pointer Indexes into
  6527. DataBases.
  6528.  
  6529. [SEE-ALSO]
  6530.  
  6531. PtrAdd
  6532.  
  6533. [EXAMPLE]
  6534.  
  6535.  
  6536. VAR
  6537.   P   : POINTER;
  6538.   Len : INTEGER;
  6539.  
  6540. BEGIN
  6541.  
  6542.   P   := NewString( 300, 'This is a Test'+#0 );
  6543.   { P is now a "C"-Type String }
  6544.  
  6545.   Len := 0;
  6546.  
  6547.   While ( P <> #0) Do
  6548.   BEGIN
  6549.     Inc( Len );
  6550.     P := PtrAdd( P, 1 );
  6551.   END;
  6552.  
  6553.   P := PtrSub( P, Len );
  6554.  
  6555.   {------------------------------------------------------}
  6556.   { "Len" now equals the length of the AsciiZ string     }
  6557.   { while "P" is returned to the original string address }
  6558.   {------------------------------------------------------}
  6559.  
  6560.  
  6561.   {-------------------------------------------------}
  6562.   { GRANTED THIS IS NOT AN EXAMPLE OF OPTIMAL USAGE }
  6563.   { BUT IT DOES SHOW THE ACTION.                    }
  6564.   {-------------------------------------------------}
  6565.  
  6566. END;
  6567.  
  6568.  
  6569. ──────────────────────────────────────────────────────────────────────────────
  6570.  
  6571.  
  6572. [FUNCTION]
  6573.  
  6574. Function  NewString(                 StringLen : WORD;
  6575.                                      DefString : STRING  ) : POINTER;
  6576.  
  6577. [PARAMETERS]
  6578.  
  6579. StringLen   Maximum string length to allocate
  6580. DefString   Default new string text
  6581.  
  6582. [RETURNS]
  6583.  
  6584. Pointer to New String and data.
  6585.  
  6586. [DESCRIPTION]
  6587.  
  6588. This function allows dynamic creation of strings on the heap.  Based
  6589. upon the greater of the StringLen or the DefString Length, it will
  6590. allocate memory on the heap in which to store not only the string data
  6591. but also the size of the memory block allocated (for deallocation
  6592. purposes).  This string can now be used in functions just as you would
  6593. any other -but making sure to address the data and not just the pointer.
  6594.  
  6595. There are advantages in obtaining strings from Heap Memory as opposed
  6596. to the Stack, not the least of which is the fact that the Heap is larger
  6597. and more Dynamic where the Stack has to be set at Compile Time.
  6598.  
  6599. [SEE-ALSO]
  6600.  
  6601. GetHeapString
  6602. DisposeString
  6603.  
  6604. [EXAMPLE]
  6605.  
  6606. VAR
  6607.   P : POINTER;
  6608.  
  6609. BEGIN
  6610.  
  6611.   P := NewString( 'This is the String' );
  6612.  
  6613.   { P now points to the String Data as well as the Memory Allocations }
  6614.  
  6615. END;
  6616.  
  6617.  
  6618. ──────────────────────────────────────────────────────────────────────────────
  6619.  
  6620.  
  6621. [FUNCTION]
  6622.  
  6623. Function GetHeapString(      HeapStringPtr : PString ) : STRING;
  6624.  
  6625. [PARAMETERS]
  6626.  
  6627. HeapStringPtr   String Pointer
  6628.  
  6629. [RETURNS]
  6630.  
  6631. Pascal String in Heap Memory
  6632.  
  6633. [DESCRIPTION]
  6634.  
  6635. This is the
  6636.  
  6637. There are advantages in obtaining strings from Heap Memory as opposed
  6638. to the Stack, not the least of which is the fact that the Heap is larger
  6639. and more Dynamic where the Stack has to be set at Compile Time.
  6640.  
  6641. [SEE-ALSO]
  6642.  
  6643. NewString
  6644. DisposeString
  6645.  
  6646. [EXAMPLE]
  6647.  
  6648. VAR
  6649.   S : STRING;
  6650.  
  6651. BEGIN
  6652.  
  6653.   S := GetHeapString( NewString( 'This is the String' ) );
  6654.  
  6655.   {--------------------------------------------------------------------}
  6656.   { S now contains "This is the String" from the Dynamically allocated }
  6657.   { from the Heap while the String Pointer itself also includes the    }
  6658.   { Memory Allocation associated with this String Pointer              }
  6659.   {--------------------------------------------------------------------}
  6660.  
  6661. END;
  6662.  
  6663.  
  6664. ──────────────────────────────────────────────────────────────────────────────
  6665.  
  6666.  
  6667. [FUNCTION]
  6668.  
  6669. Procedure DisposeString(             PrevNewString : POINTER );
  6670.  
  6671. [PARAMETERS]
  6672.  
  6673. PrevNewString   Existing String pointer created by NewString
  6674.  
  6675. [RETURNS]
  6676.  
  6677. (None)
  6678.  
  6679. [DESCRIPTION]
  6680.  
  6681. This is the complementary function to NewString.  It will take the
  6682. NewString string pointer and deallocate it from the heap.  It should
  6683. be noted that all the information about the allocated memory size is
  6684. already contained with the string pointer data, thus deallocation is
  6685. completely invisible to the user.
  6686.  
  6687. [SEE-ALSO]
  6688.  
  6689. NewString
  6690. GetHeapString
  6691.  
  6692. [EXAMPLE]
  6693.  
  6694. VAR
  6695.   P : POINTER;
  6696.  
  6697. BEGIN
  6698.  
  6699.   P := NewString( 'This is the String' );
  6700.   { P now points to the String Data as well as the Memory Allocations }
  6701.  
  6702.   DisposeString( P );
  6703.  
  6704.   {-----------------------------------}
  6705.   { P now is an unassigned pointer,   }
  6706.   { all memory associated with it has }
  6707.   { been deallocated                  }
  6708.   {-----------------------------------}
  6709.  
  6710. END;
  6711.  
  6712.  
  6713. ──────────────────────────────────────────────────────────────────────────────
  6714.  
  6715.  
  6716. [FUNCTION]
  6717.  
  6718. Procedure FarCall(          Proc          : POINTER );
  6719.  
  6720. [PARAMETERS]
  6721.  
  6722. Proc        Far Pointer to Procedure to Call
  6723.  
  6724. [RETURNS]
  6725.  
  6726. (None)
  6727.  
  6728. [DESCRIPTION]
  6729.  
  6730. Jumps to the Far Pointer and executes the Procedure.
  6731.  
  6732. NOTE: Caller must be sure to declare his Procedures to be called
  6733. as Far Procedures as shown in the Example below.
  6734.  
  6735. [SEE-ALSO]
  6736.  
  6737. (None)
  6738.  
  6739. [EXAMPLE]
  6740.  
  6741. Procedure MyRoutine; Far
  6742. BEGIN
  6743.   WriteLn( 'Something to Do.');
  6744. END;
  6745.  
  6746. BEGIN
  6747.  
  6748.   FarCall( @MyRoutine );
  6749.  
  6750. END.
  6751.  
  6752.